Class: Formeze::FieldSet

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/formeze.rb

Instance Method Summary collapse

Constructor Details

#initializeFieldSet

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