Module: Autopopulater::Autopopulated

Extended by:
ActiveSupport::Concern
Defined in:
lib/autopopulater/autopopulated.rb

Instance Method Summary collapse

Instance Method Details

#autopopulate_attributesObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/autopopulater/autopopulated.rb', line 21

def autopopulate_attributes
  self.class.autopopulated_attributes.each do |a|
    value = fetch_value(a[:with])

    a[:keys].each do |attr|
      next unless send(attr).blank?

      send("#{attr}=", attr_value(value, attr))
    end
  end
end