Class: Puffer::FieldSet
- Inherits:
-
Array
- Object
- Array
- Puffer::FieldSet
- Defined in:
- lib/puffer/field_set.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #columns ⇒ Object
- #copy_to(fieldset, model) ⇒ Object
- #field(name, resource, options, &block) ⇒ Object
-
#initialize(name = nil) ⇒ FieldSet
constructor
A new instance of FieldSet.
Constructor Details
#initialize(name = nil) ⇒ FieldSet
Returns a new instance of FieldSet.
6 7 8 9 |
# File 'lib/puffer/field_set.rb', line 6 def initialize name = nil @name = name super() end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/puffer/field_set.rb', line 4 def name @name end |
Instance Method Details
#[](key) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/puffer/field_set.rb', line 20 def [] key if key.is_a?(String) || key.is_a?(Symbol) detect {|f| f.field_name == key.to_s} else super end end |
#columns ⇒ Object
16 17 18 |
# File 'lib/puffer/field_set.rb', line 16 def columns select {|f| f.column}.to_fieldset end |
#copy_to(fieldset, model) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/puffer/field_set.rb', line 28 def copy_to fieldset, model each do |f| new_field = fieldset.field f.field_name, model, f. f.children.copy_to new_field.children, swallow_nil{new_field.reflection.klass} end end |