Class: Formeze::FieldSet
Instance Method Summary collapse
- #<<(field) ⇒ Object
- #[](field_name) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize ⇒ FieldSet
constructor
A new instance of FieldSet.
Constructor Details
#initialize ⇒ FieldSet
Returns a new instance of FieldSet.
131 132 133 |
# File 'lib/formeze.rb', line 131 def initialize @fields, @index = [], {} end |
Instance Method Details
#<<(field) ⇒ Object
139 140 141 142 143 |
# File 'lib/formeze.rb', line 139 def <<(field) @fields << field @index[field.name] = field end |
#[](field_name) ⇒ Object
145 146 147 |
# File 'lib/formeze.rb', line 145 def [](field_name) @index.fetch(field_name) end |
#each(&block) ⇒ Object
135 136 137 |
# File 'lib/formeze.rb', line 135 def each(&block) @fields.each(&block) end |