Class: ConvenientService::Config::Entities::OptionCollection
- Inherits:
-
Object
- Object
- ConvenientService::Config::Entities::OptionCollection
- Defined in:
- lib/convenient_service/config/entities/option_collection.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #==(other) ⇒ Boolean?
- #[](name) ⇒ Boolean
- #any? ⇒ Boolean
- #dup ⇒ ConvenientService::Config::Entities::OptionCollection
- #include?(name) ⇒ Boolean
- #initialize(options: {}) ⇒ void constructor
- #keys ⇒ Array<Symbol>
- #merge(other_options) ⇒ ConvenientService::Config::Entities::OptionCollection
- #replace(other_options) ⇒ ConvenientService::Config::Entities::OptionCollection
- #subtract(other_options) ⇒ ConvenientService::Config::Entities::OptionCollection
- #to_a ⇒ Array<ConvenientService::Config::Entities::Option>
- #to_h ⇒ Hash{Symbol => ConvenientService::Config::Entities::Option}
Constructor Details
#initialize(options: {}) ⇒ void
29 30 31 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 29 def initialize(options: {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
20 21 22 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 20 def @options end |
Instance Method Details
#==(other) ⇒ Boolean?
124 125 126 127 128 129 130 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 124 def ==(other) return unless other.instance_of?(self.class) return false if != other. true end |
#[](name) ⇒ Boolean
67 68 69 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 67 def [](name) [name] end |
#any? ⇒ Boolean
46 47 48 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 46 def any? .any? { |_name, option| option.enabled? } end |
#dup ⇒ ConvenientService::Config::Entities::OptionCollection
77 78 79 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 77 def dup self.class.new(options: .dup) end |
#include?(name) ⇒ Boolean
57 58 59 60 61 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 57 def include?(name) return false unless .has_key?(name) [name].enabled? end |
#keys ⇒ Array<Symbol>
36 37 38 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 36 def keys .keys end |
#merge(other_options) ⇒ ConvenientService::Config::Entities::OptionCollection
88 89 90 91 92 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 88 def merge() .merge!(Commands::NormalizeOptions[options: ].to_h) self end |
#replace(other_options) ⇒ ConvenientService::Config::Entities::OptionCollection
114 115 116 117 118 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 114 def replace() .replace(Commands::NormalizeOptions[options: ].to_h) self end |
#subtract(other_options) ⇒ ConvenientService::Config::Entities::OptionCollection
101 102 103 104 105 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 101 def subtract() Commands::NormalizeOptions[options: ].to_h.each_key { |name| .delete(name) } self end |
#to_a ⇒ Array<ConvenientService::Config::Entities::Option>
135 136 137 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 135 def to_a .values end |
#to_h ⇒ Hash{Symbol => ConvenientService::Config::Entities::Option}
142 143 144 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 142 def to_h end |