Module: Reform::Contract::Setup
Defined Under Namespace
Modules: Readable, SetupOptions
Instance Method Summary
collapse
Methods included from Readable
#setup_options
#setup_options
Instance Method Details
#create_fields(field_names, fields) ⇒ Object
28
29
30
|
# File 'lib/reform/contract/setup.rb', line 28
def create_fields(field_names, fields)
Fields.new(field_names, fields)
end
|
#initialize(model) ⇒ Object
4
5
6
7
|
# File 'lib/reform/contract/setup.rb', line 4
def initialize(model)
@model = model @fields = setup_fields end
|
#setup_fields ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/reform/contract/setup.rb', line 20
def setup_fields
representer = setup_representer.new(aliased_model)
options = setup_options(Reform::Representer::Options[])
create_fields(mapper.fields, representer.to_hash(options))
end
|
#setup_representer ⇒ Object
Setup#to_hash will create a nested hash of property values from the model. Nested properties will be recursively wrapped in a form instance.
11
12
13
14
15
16
17
18
|
# File 'lib/reform/contract/setup.rb', line 11
def setup_representer
self.class.representer(:setup) do |dfn| dfn.merge!(
:representable => false, :prepare => lambda { |model, args| args.binding[:form].new(model) } )
end
end
|