module GovUkDateFields::ActsAsGovUkDate::LocalInstanceMethods
Public Instance Methods
populate_gov_uk_dates()
click to toggle source
This is an after initialize method. We want to populate every gov_uk_date_field, unless it's a new record, and there is already a non-nil form date (this happens when you call new and pass a hash of attributes and values)
# File lib/gov_uk_date_fields/acts_as_gov_uk_date.rb, line 115 def populate_gov_uk_dates self._gov_uk_dates.each do |field_name| instance_variable_name = "@_#{field_name}" next if self.new_record? && self.instance_variable_defined?(instance_variable_name) && self.instance_variable_get(instance_variable_name) != nil GovUkDateFields::FormDate.set_from_date(self, field_name, self[field_name]) end end