module SuperForm::Fieldable

Public Instance Methods

field(name) click to toggle source
# File lib/super_form/fieldable.rb, line 22
def field(name)
  fields.fetch(name)
end
fields() click to toggle source
# File lib/super_form/fieldable.rb, line 15
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) click to toggle source
# File lib/super_form/fieldable.rb, line 36
def fieldset(id)
  fieldsets.fetch(id)
end
fieldsets() click to toggle source
# File lib/super_form/fieldable.rb, line 26
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