Class: Rectify::BuildFormFromModel
- Inherits:
-
Object
- Object
- Rectify::BuildFormFromModel
- Defined in:
- lib/rectify/build_form_from_model.rb
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(form_class, model) ⇒ BuildFormFromModel
constructor
A new instance of BuildFormFromModel.
Constructor Details
#initialize(form_class, model) ⇒ BuildFormFromModel
Returns a new instance of BuildFormFromModel.
3 4 5 6 |
# File 'lib/rectify/build_form_from_model.rb', line 3 def initialize(form_class, model) @form_class = form_class @model = model end |
Instance Method Details
#build ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rectify/build_form_from_model.rb', line 8 def build form.tap do matching_attributes.each do |a| model_value = model.public_send(a.name) form.public_send("#{a.name}=", a.value_from(model_value)) end form.map_model(model) end end |