class Dry::Configurable::Settings
A collection of defined settings on a given class.
@api private
Attributes
settings[R]
@api private
Public Class Methods
new(settings = EMPTY_ARRAY)
click to toggle source
@api private
# 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
Public Instance Methods
<<(setting)
click to toggle source
@api private
# File lib/dry/configurable/settings.rb, line 27 def <<(setting) settings[setting.name] = setting self end
[](name)
click to toggle source
Returns the setting for the given name, if found.
@return [Setting, nil] the setting, or nil if not found
@api public
# File lib/dry/configurable/settings.rb, line 37 def [](name) settings[name] end
each(&block)
click to toggle source
@api public
# File lib/dry/configurable/settings.rb, line 60 def each(&block) settings.each_value(&block) end
key?(name)
click to toggle source
Returns true if a setting for the given name is defined.
@return [Boolean]
@api public
# File lib/dry/configurable/settings.rb, line 46 def key?(name) keys.include?(name) end
keys()
click to toggle source
Returns the list of defined setting names.
@return [Array<Symbol>]
@api public
# File lib/dry/configurable/settings.rb, line 55 def keys settings.keys end
Private Instance Methods
initialize_copy(source)
click to toggle source
@api private
# File lib/dry/configurable/settings.rb, line 22 def initialize_copy(source) @settings = source.settings.dup end