Class: SuperForm::Fieldset
- Inherits:
-
Object
- Object
- SuperForm::Fieldset
- Includes:
- Enumerable
- Defined in:
- lib/super_form/fieldset.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #<<(field) ⇒ Object
- #[](field_id) ⇒ Object
- #add_field(field) ⇒ Object
- #each(&block) ⇒ Object
- #field(field_id) ⇒ Object
-
#initialize(id) ⇒ Fieldset
constructor
A new instance of Fieldset.
Constructor Details
#initialize(id) ⇒ Fieldset
Returns a new instance of Fieldset.
7 8 9 10 |
# File 'lib/super_form/fieldset.rb', line 7 def initialize(id) @id = id @fields = {} end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
5 6 7 |
# File 'lib/super_form/fieldset.rb', line 5 def fields @fields end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/super_form/fieldset.rb', line 5 def id @id end |
Instance Method Details
#<<(field) ⇒ Object
16 17 18 |
# File 'lib/super_form/fieldset.rb', line 16 def <<(field) add_field(field) end |
#[](field_id) ⇒ Object
24 25 26 |
# File 'lib/super_form/fieldset.rb', line 24 def [](field_id) field(field_id) end |
#add_field(field) ⇒ Object
12 13 14 |
# File 'lib/super_form/fieldset.rb', line 12 def add_field(field) @fields[field.name] = field end |
#each(&block) ⇒ Object
28 29 30 |
# File 'lib/super_form/fieldset.rb', line 28 def each(&block) @fields.each { |field_id| block.call(field_id) } end |
#field(field_id) ⇒ Object
20 21 22 |
# File 'lib/super_form/fieldset.rb', line 20 def field(field_id) @fields[field_id] end |