module ActiveModel::AttributeAssignment

Private Instance Methods

_assign_attribute(k, v) click to toggle source
# File lib/active_model/assign_attributes.rb, line 4
def _assign_attribute(k, v)
  if respond_to?("#{k}=")
    public_send("#{k}=", _assign_attribute_value(k, v))
  else
    raise UnknownAttributeError.new(self, k)
  end
end
_assign_attribute_value(key, value) click to toggle source
# File lib/active_model/assign_attributes.rb, line 12
def _assign_attribute_value(key, value)
  if self.class.declared_coercions.include?(key.to_sym)
    self.attributes[key.to_sym] = self.class.declared_coercions[key.to_sym].cast(value)
  else
    self.attributes[key.to_sym] = value
  end
end