Class: Dry::Configurable::Settings Private
- Inherits:
-
Object
- Object
- Dry::Configurable::Settings
- Includes:
- Enumerable
- Defined in:
- lib/dry/configurable/settings.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A collection of defined settings on a given class.
Instance Attribute Summary collapse
- #settings ⇒ Object readonly private
Instance Method Summary collapse
- #<<(setting) ⇒ Object private
-
#[](name) ⇒ Setting?
Returns the setting for the given name, if found.
- #each(&block) ⇒ Object
-
#initialize(settings = EMPTY_ARRAY) ⇒ Settings
constructor
private
A new instance of Settings.
-
#key?(name) ⇒ Boolean
Returns true if a setting for the given name is defined.
-
#keys ⇒ Array<Symbol>
Returns the list of defined setting names.
Constructor Details
#initialize(settings = EMPTY_ARRAY) ⇒ Settings
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Settings.
17 18 19 |
# File 'lib/dry/configurable/settings.rb', line 17 def initialize(settings = EMPTY_ARRAY) @settings = settings.each_with_object({}) { |s, m| m[s.name] = s } end |
Instance Attribute Details
#settings ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/dry/configurable/settings.rb', line 14 def settings @settings end |
Instance Method Details
#<<(setting) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 |
# File 'lib/dry/configurable/settings.rb', line 27 def <<(setting) settings[setting.name] = setting self end |
#[](name) ⇒ Setting?
Returns the setting for the given name, if found.
37 38 39 |
# File 'lib/dry/configurable/settings.rb', line 37 def [](name) settings[name] end |
#each(&block) ⇒ Object
60 61 62 |
# File 'lib/dry/configurable/settings.rb', line 60 def each(&block) settings.each_value(&block) end |
#key?(name) ⇒ Boolean
Returns true if a setting for the given name is defined.
46 47 48 |
# File 'lib/dry/configurable/settings.rb', line 46 def key?(name) keys.include?(name) end |
#keys ⇒ Array<Symbol>
Returns the list of defined setting names.
55 56 57 |
# File 'lib/dry/configurable/settings.rb', line 55 def keys settings.keys end |