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
- #disabled?(name) ⇒ Boolean
- #dup ⇒ ConvenientService::Config::Entities::OptionCollection
- #enabled?(name) ⇒ Boolean
- #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?
137 138 139 140 141 142 143 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 137 def ==(other) return unless other.instance_of?(self.class) return false if != other. true end |
#[](name) ⇒ Boolean
80 81 82 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 80 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 |
#disabled?(name) ⇒ Boolean
72 73 74 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 72 def disabled?(name) !enabled?(name) end |
#dup ⇒ ConvenientService::Config::Entities::OptionCollection
90 91 92 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 90 def dup self.class.new(options: .dup) end |
#enabled?(name) ⇒ Boolean
62 63 64 65 66 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 62 def enabled?(name) return false unless include?(name) [name].enabled? end |
#include?(name) ⇒ Boolean
54 55 56 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 54 def include?(name) .has_key?(name) 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
101 102 103 104 105 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 101 def merge() .merge!(Commands::NormalizeOptions[options: ].to_h) self end |
#replace(other_options) ⇒ ConvenientService::Config::Entities::OptionCollection
127 128 129 130 131 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 127 def replace() .replace(Commands::NormalizeOptions[options: ].to_h) self end |
#subtract(other_options) ⇒ ConvenientService::Config::Entities::OptionCollection
114 115 116 117 118 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 114 def subtract() Commands::NormalizeOptions[options: ].to_h.each_key { |name| .delete(name) } self end |
#to_a ⇒ Array<ConvenientService::Config::Entities::Option>
148 149 150 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 148 def to_a .values end |
#to_h ⇒ Hash{Symbol => ConvenientService::Config::Entities::Option}
155 156 157 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 155 def to_h end |