Class: Plutonium::Wizard::Data::StructuredRow
- Inherits:
-
Object
- Object
- Plutonium::Wizard::Data::StructuredRow
- Defined in:
- lib/plutonium/wizard/data.rb
Overview
A read-only row inside a structured collection. Responds to each declared sub-field; values are exposed as-is (string-typed, since structured inputs carry no scalar type declarations).
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(fields, values) ⇒ StructuredRow
constructor
A new instance of StructuredRow.
- #to_h ⇒ Object
Constructor Details
#initialize(fields, values) ⇒ StructuredRow
Returns a new instance of StructuredRow.
21 22 23 24 25 26 |
# File 'lib/plutonium/wizard/data.rb', line 21 def initialize(fields, values) @values = values fields.each do |field| define_singleton_method(field) { @values[field.to_s] } end end |
Instance Method Details
#[](key) ⇒ Object
28 |
# File 'lib/plutonium/wizard/data.rb', line 28 def [](key) = @values[key.to_s] |
#to_h ⇒ Object
30 |
# File 'lib/plutonium/wizard/data.rb', line 30 def to_h = @values.dup |