Module: SuperForm::Fieldable
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Model
- Included in:
- SuperForm
- Defined in:
- lib/super_form/fieldable.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#field(name) ⇒ Object
17 18 19 |
# File 'lib/super_form/fieldable.rb', line 17 def field(name) fields.fetch(name) end |
#fields ⇒ Object
10 11 12 13 14 15 |
# File 'lib/super_form/fieldable.rb', line 10 def fields @fields ||= self.class.fields.each_with_object({}) do |field, f| f[field.name] = field.dup f[field.name].form = self end end |
#fieldset(id) ⇒ Object
31 32 33 |
# File 'lib/super_form/fieldable.rb', line 31 def fieldset(id) fieldsets.fetch(id) end |
#fieldsets ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/super_form/fieldable.rb', line 21 def fieldsets @fieldsets ||= self.class.fieldsets.each_with_object({}) do |fieldset, f| id, fields = fieldset fields.each_with_object(f) do |field| (f[id] ||= Fieldset.new(id)) << self.field(field) end end end |