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.



26
27
28
# File 'lib/convenient_service/config/entities/options.rb', line 26

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

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



20
21
22
# File 'lib/convenient_service/config/entities/options.rb', line 20

def options
  @options
end

Instance Method Details

#==(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


103
104
105
106
107
108
109
# File 'lib/convenient_service/config/entities/options.rb', line 103

def ==(other)
  return unless other.instance_of?(self.class)

  return false if options != other.options

  true
end

#[](name) ⇒ Boolean

Parameters:

  • name (Symbol)

Returns:

  • (Boolean)


58
59
60
# File 'lib/convenient_service/config/entities/options.rb', line 58

def [](name)
  options[name]
end

#any?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/convenient_service/config/entities/options.rb', line 40

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

#dupConvenientService::Config::Entities::Options



65
66
67
# File 'lib/convenient_service/config/entities/options.rb', line 65

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

#include?(name) ⇒ Boolean

Parameters:

  • name (Symbol)

Returns:

  • (Boolean)


48
49
50
51
52
# File 'lib/convenient_service/config/entities/options.rb', line 48

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

  options[name].enabled?
end

#keysArray<Symbol>

Returns:

  • (Array<Symbol>)


33
34
35
# File 'lib/convenient_service/config/entities/options.rb', line 33

def keys
  options.keys
end

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



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

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

  self
end

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



90
91
92
93
94
# File 'lib/convenient_service/config/entities/options.rb', line 90

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

  self
end

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



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

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

  self
end

#to_aArray

Returns:

  • (Array)


114
115
116
# File 'lib/convenient_service/config/entities/options.rb', line 114

def to_a
  options.values
end