Module: Id::Form::Descriptor

Defined in:
lib/id/form/descriptor.rb

Instance Method Summary collapse

Instance Method Details

#field(f, options = {}) ⇒ Object



5
6
7
# File 'lib/id/form/descriptor.rb', line 5

def field(f, options={})
  FieldWithFormSupport.new(self, f, options).define
end

#form(&block) ⇒ Object



9
10
11
# File 'lib/id/form/descriptor.rb', line 9

def form &block
  form_object.send :instance_exec, &block
end

#form_objectObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/id/form/descriptor.rb', line 13

def form_object
  base = self
  @form_object ||= Class.new(ActiveModelForm) do
    eingenclass = class << self
      self
    end
    eingenclass.send(:define_method, :model_name) do
      ActiveModel::Name.new(self, nil, base.name)
    end
  end
end