module FreeForm::Property

Public Class Methods

included(base) click to toggle source
# File lib/freeform/form/property.rb, line 5
def self.included(base)
  base.extend(ClassMethods)
end

Public Instance Methods

after_assign_params(params) click to toggle source
# File lib/freeform/form/property.rb, line 73
def after_assign_params(params)
end
assign_attributes(params)
Alias for: assign_params
assign_params(params) click to toggle source
# File lib/freeform/form/property.rb, line 55
def assign_params(params)
  formatted_params = params.stringify_keys
  self.tap do |s|
    FreeForm::DateParamsFilter.new.call(formatted_params)
    before_assign_params(formatted_params)
    formatted_params.each_pair do |attribute, value|
      assign_attribute(attribute, value)
    end
    after_assign_params(formatted_params)
  end
end
Also aliased as: assign_attributes, populate, fill
before_assign_params(params) click to toggle source
# File lib/freeform/form/property.rb, line 70
def before_assign_params(params)
end
fill(params)
Alias for: assign_params
model_property_mappings() click to toggle source
# File lib/freeform/form/property.rb, line 76
def model_property_mappings
  self.class.property_mappings
end
populate(params)
Alias for: assign_params

Private Instance Methods

assign_attribute(attribute, value) click to toggle source
# File lib/freeform/form/property.rb, line 81
def assign_attribute(attribute, value)
  self.send :"#{attribute}=", value unless ignore?(attribute, value)
end
ignore?(attribute, value) click to toggle source
# File lib/freeform/form/property.rb, line 85
def ignore?(attribute, value)
  mapping = model_property_mappings[attribute.to_sym]
  if mapping.present?
    mapping[:ignore_blank] && value.blank?
  else
    false
  end
end