Module: Reform::Form::Composition
- Defined in:
- lib/reform/form/composition.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
Automatically creates a Composition object for you when initializing the form.
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
Automatically creates a Composition object for you when initializing the form.
5 6 7 8 9 10 |
# File 'lib/reform/form/composition.rb', line 5 def self.included(base) base.class_eval do extend Reform::Form::ActiveModel::ClassMethods # ::model. extend ClassMethods end end |
Instance Method Details
#initialize(models) ⇒ Object
57 58 59 60 |
# File 'lib/reform/form/composition.rb', line 57 def initialize(models) composition = self.class.model_class.new(models) super(composition) end |
#to_hash(*args) ⇒ Object
66 67 68 |
# File 'lib/reform/form/composition.rb', line 66 def to_hash(*args) mapper.new(fields).to_hash(*args) end |
#to_nested_hash ⇒ Object
62 63 64 |
# File 'lib/reform/form/composition.rb', line 62 def to_nested_hash model.nested_hash_for(to_hash) # use composition to compute nested hash. end |