Module: Reform::Form::Validate::Populator
- Defined in:
- lib/reform/form/validate.rb
Defined Under Namespace
Classes: PopulateIfEmpty
Instance Method Summary collapse
Instance Method Details
#from_hash(params, args) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/reform/form/validate.rb', line 59 def from_hash(params, args) populated_attrs = [] nested_forms do |attr| next unless attr[:populate_if_empty] attr.merge!( # DISCUSS: it would be cool to move the lambda block to PopulateIfEmpty#call. :populator => lambda do |fragment, *args| PopulateIfEmpty.new(self, fragment, args).call end ) end nested_forms do |attr| next unless attr[:populator] attr.merge!( :parse_strategy => attr[:populator], :representable => false ) populated_attrs << attr.name.to_sym end super(params, {:include => populated_attrs}.merge(args)) end |