Class: ConvenientService::Config::Entities::OptionCollection
- Inherits:
-
Object
- Object
- ConvenientService::Config::Entities::OptionCollection
- Defined in:
- lib/convenient_service/config/entities/option_collection.rb
Overview
Instance Attribute Summary collapse
- #options ⇒ Object readonly
Instance Method Summary collapse
- #==(other) ⇒ Boolean?
- #[](name) ⇒ Boolean
- #any? ⇒ Boolean
- #any_enabled?(*names) ⇒ 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
25 26 27 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 25 def initialize(options: {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
16 17 18 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 16 def @options end |
Instance Method Details
#==(other) ⇒ Boolean?
141 142 143 144 145 146 147 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 141 def ==(other) return unless other.instance_of?(self.class) return false if != other. true end |
#[](name) ⇒ Boolean
84 85 86 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 84 def [](name) [name] end |
#any? ⇒ Boolean
42 43 44 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 42 def any? .any? { |_name, option| option.enabled? } end |
#any_enabled?(*names) ⇒ Boolean
68 69 70 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 68 def any_enabled?(*names) names.any? { |name| enabled?(name) } end |
#disabled?(name) ⇒ Boolean
76 77 78 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 76 def disabled?(name) !enabled?(name) end |
#dup ⇒ ConvenientService::Config::Entities::OptionCollection
94 95 96 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 94 def dup self.class.new(options: .dup) end |
#enabled?(name) ⇒ Boolean
58 59 60 61 62 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 58 def enabled?(name) return false unless include?(name) [name].enabled? end |
#include?(name) ⇒ Boolean
50 51 52 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 50 def include?(name) .has_key?(name) end |
#keys ⇒ Array<Symbol>
32 33 34 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 32 def keys .keys end |
#merge(other_options) ⇒ ConvenientService::Config::Entities::OptionCollection
105 106 107 108 109 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 105 def merge() .merge!(Commands::NormalizeOptions[options: ].to_h) self end |
#replace(other_options) ⇒ ConvenientService::Config::Entities::OptionCollection
131 132 133 134 135 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 131 def replace() .replace(Commands::NormalizeOptions[options: ].to_h) self end |
#subtract(other_options) ⇒ ConvenientService::Config::Entities::OptionCollection
118 119 120 121 122 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 118 def subtract() Commands::NormalizeOptions[options: ].to_h.each_key { |name| .delete(name) } self end |
#to_a ⇒ Array<ConvenientService::Config::Entities::Option>
152 153 154 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 152 def to_a .values end |
#to_h ⇒ Hash{Symbol => ConvenientService::Config::Entities::Option}
159 160 161 |
# File 'lib/convenient_service/config/entities/option_collection.rb', line 159 def to_h end |