Class: Plumbum::ManyProvider
- Inherits:
-
Object
- Object
- Plumbum::ManyProvider
- Includes:
- Providers::Plural
- Defined in:
- lib/plumbum/many_provider.rb
Overview
Provider that provides a mapping of keys to values.
Instance Method Summary collapse
-
#initialize(values: Plumbum::UNDEFINED, **options) ⇒ ManyProvider
constructor
A new instance of ManyProvider.
-
#values ⇒ Hash
The key-value pairs returned by the provider.
- #values=(values) ⇒ Object
Methods included from Provider
#get, #has?, #options, #read_only?, #set, #write_once?
Constructor Details
#initialize(values: Plumbum::UNDEFINED, **options) ⇒ ManyProvider
Returns a new instance of ManyProvider.
13 14 15 16 17 18 |
# File 'lib/plumbum/many_provider.rb', line 13 def initialize(values: Plumbum::UNDEFINED, **) super() @values = normalize_values(values) @options = () end |
Instance Method Details
#values ⇒ Hash
Returns the key-value pairs returned by the provider.
21 22 23 |
# File 'lib/plumbum/many_provider.rb', line 21 def values @values == Plumbum::UNDEFINED ? {} : super.dup end |
#values=(values) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/plumbum/many_provider.rb', line 26 def values=(values) validate_values(values) values = values.transform_keys(&:to_s) changed_values = find_changed_values(values) changed_values.each_key { |key| require_mutable(key) } @values = self.values.merge(changed_values) end |