Module: Reform::Form::PropertyMethods

Extended by:
Forwardable
Included in:
Reform::Form
Defined in:
lib/reform/form.rb

Instance Method Summary collapse

Instance Method Details

#collection(name, options = {}, &block) ⇒ Object



31
32
33
34
35
# File 'lib/reform/form.rb', line 31

def collection(name, options={}, &block)
  options[:form_collection] = true

  property(name, options, &block)
end

#properties(names, *args) ⇒ Object



37
38
39
# File 'lib/reform/form.rb', line 37

def properties(names, *args)
  names.each { |name| property(name, *args) }
end

#property(name, options = {}, &block) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/reform/form.rb', line 22

def property(name, options={}, &block)
  process_options(name, options, &block)

  definition = representer_class.property(name, options, &block)
  setup_form_definition(definition) if block_given? or options[:form]

  create_accessor(name)
end

#setup_form_definition(definition) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/reform/form.rb', line 41

def setup_form_definition(definition)
  # TODO: allow Definition.form?
  definition.options[:form] ||= definition.options.delete(:extend)

  definition.options[:parse_strategy] = :sync
  definition.options[:instance] = true # just to make typed? work
end