Module: Reform::Form::Composition

Included in:
DSL
Defined in:
lib/reform/form/composition.rb

Overview

Automatically creates a Composition object for you when initializing the form.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
# File 'lib/reform/form/composition.rb', line 6

def self.included(base)
  base.class_eval do
    extend ClassMethods
  end
end

Instance Method Details

#initialize(models) ⇒ Object



46
47
48
49
# File 'lib/reform/form/composition.rb', line 46

def initialize(models)
  composition = self.class.model_class.new(models)
  super(composition)
end

#to_nested_hashObject



51
52
53
# File 'lib/reform/form/composition.rb', line 51

def to_nested_hash
  model.nested_hash_for(to_hash)  # use composition to compute nested hash.
end