Class: Igniter::Contracts::Execution::NamedValues
- Inherits:
-
Object
- Object
- Igniter::Contracts::Execution::NamedValues
- Defined in:
- lib/igniter/contracts/execution/named_values.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #fetch(name) ⇒ Object
-
#initialize(values = {}) ⇒ NamedValues
constructor
A new instance of NamedValues.
- #key?(name) ⇒ Boolean
- #keys ⇒ Object
- #length ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(values = {}) ⇒ NamedValues
Returns a new instance of NamedValues.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/igniter/contracts/execution/named_values.rb', line 7 def initialize(values = {}) normalized_values = case values when NamedValues values.to_h when MutableNamedValues values.snapshot.to_h else values end @values = normalized_values.transform_keys(&:to_sym).freeze freeze end |
Instance Method Details
#[](name) ⇒ Object
26 27 28 |
# File 'lib/igniter/contracts/execution/named_values.rb', line 26 def [](name) @values[name.to_sym] end |
#fetch(name) ⇒ Object
22 23 24 |
# File 'lib/igniter/contracts/execution/named_values.rb', line 22 def fetch(name) @values.fetch(name.to_sym) end |
#key?(name) ⇒ Boolean
30 31 32 |
# File 'lib/igniter/contracts/execution/named_values.rb', line 30 def key?(name) @values.key?(name.to_sym) end |
#keys ⇒ Object
34 35 36 |
# File 'lib/igniter/contracts/execution/named_values.rb', line 34 def keys @values.keys end |
#length ⇒ Object
38 39 40 |
# File 'lib/igniter/contracts/execution/named_values.rb', line 38 def length @values.length end |
#to_h ⇒ Object
42 43 44 |
# File 'lib/igniter/contracts/execution/named_values.rb', line 42 def to_h @values.to_h { |key, value| [key, StructuredDump.dump(value)] } end |