Sha256: 12244ebd8964254813c6f7f4e26f629a791b9e1a094f72ac775f873b45104f92

Contents?: true

Size: 672 Bytes

Versions: 18

Compression:

Stored size: 672 Bytes

Contents

# prepopulate!(options)
# prepopulator: ->(model, user_options)
module Reform::Form::Prepopulate
  def prepopulate!(options={})
    prepopulate_local!(options)  # call #prepopulate! on local properties.
    prepopulate_nested!(options) # THEN call #prepopulate! on nested forms.

    self
  end

private
  def prepopulate_local!(options)
    schema.each do |dfn|
      next unless block = dfn[:prepopulator]
      Uber::Options::Value.new(block).evaluate(self, options)
    end
  end

  def prepopulate_nested!(options)
    schema.each(twin: true) do |dfn|
      Disposable::Twin::PropertyProcessor.new(dfn, self).() { |form| form.prepopulate!(options) }
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
reform-2.2.3 lib/reform/form/prepopulate.rb
reform-2.2.2 lib/reform/form/prepopulate.rb
reform-2.2.1 lib/reform/form/prepopulate.rb
reform-2.2.0 lib/reform/form/prepopulate.rb
reform-2.2.0.rc1 lib/reform/form/prepopulate.rb
reform-2.1.0 lib/reform/form/prepopulate.rb
reform-2.1.0.rc1 lib/reform/form/prepopulate.rb
reform-2.0.5 lib/reform/form/prepopulate.rb
reform-2.0.4 lib/reform/form/prepopulate.rb
reform-2.0.3 lib/reform/form/prepopulate.rb
reform-2.0.2 lib/reform/form/prepopulate.rb
reform-2.0.1 lib/reform/form/prepopulate.rb
reform-2.0.0 lib/reform/form/prepopulate.rb
reform-2.0.0.rc3 lib/reform/form/prepopulate.rb
reform-2.0.0.rc2 lib/reform/form/prepopulate.rb
reform-2.0.0.rc1 lib/reform/form/prepopulate.rb
reform-2.0.0.beta2 lib/reform/form/prepopulate.rb
reform-2.0.0.beta1 lib/reform/form/prepopulate.rb