Class: ConvenientService::Config::Entities::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/config/entities/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options: nil) ⇒ void

Parameters:

  • options (Object) (defaults to: nil)

    Can be any type.



22
23
24
# File 'lib/convenient_service/config/entities/options.rb', line 22

def initialize(options: nil)
  @options = Commands::NormalizeOptions[options: options]
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



16
17
18
# File 'lib/convenient_service/config/entities/options.rb', line 16

def options
  @options
end

Instance Method Details

#[](name) ⇒ Boolean

Parameters:

  • name (Symbol)

Returns:

  • (Boolean)


47
48
49
# File 'lib/convenient_service/config/entities/options.rb', line 47

def [](name)
  options[name]
end

#any?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/convenient_service/config/entities/options.rb', line 29

def any?
  options.any? { |_name, option| option.enabled? }
end

#dupConvenientService::Config::Entities::Options



54
55
56
# File 'lib/convenient_service/config/entities/options.rb', line 54

def dup
  self.class.new(options: options.dup)
end

#include?(name) ⇒ Boolean

Parameters:

  • name (Symbol)

Returns:

  • (Boolean)


37
38
39
40
41
# File 'lib/convenient_service/config/entities/options.rb', line 37

def include?(name)
  return false unless options.has_key?(name)

  options[name].enabled?
end

#merge(other_options) ⇒ ConvenientService::Config::Entities::Options



61
62
63
64
65
# File 'lib/convenient_service/config/entities/options.rb', line 61

def merge(other_options)
  options.merge!(Commands::NormalizeOptions[options: other_options])

  self
end

#replace(other_options) ⇒ ConvenientService::Config::Entities::Options



79
80
81
82
83
# File 'lib/convenient_service/config/entities/options.rb', line 79

def replace(other_options)
  options.replace(Commands::NormalizeOptions[options: other_options])

  self
end

#subtract(other_options) ⇒ ConvenientService::Config::Entities::Options



70
71
72
73
74
# File 'lib/convenient_service/config/entities/options.rb', line 70

def subtract(other_options)
  Commands::NormalizeOptions[options: other_options].each_key { |name| options.delete(name) }

  self
end

#to_aArray

Returns:

  • (Array)


88
89
90
# File 'lib/convenient_service/config/entities/options.rb', line 88

def to_a
  options.values
end