module ActiveRecord::AttributeMethods::Write
Constants
- WriterMethodCache
Public Instance Methods
raw_write_attribute(attr_name, value)
click to toggle source
# File lib/active_record/attribute_methods/write.rb, line 59 def raw_write_attribute(attr_name, value) write_attribute_with_type_cast(attr_name, value, false) end
write_attribute(attr_name, value)
click to toggle source
Updates the attribute identified by attr_name
with the
specified value
. Empty strings for fixnum and float columns
are turned into nil
.
# File lib/active_record/attribute_methods/write.rb, line 55 def write_attribute(attr_name, value) write_attribute_with_type_cast(attr_name, value, true) end
Private Instance Methods
attribute=(attribute_name, value)
click to toggle source
Handle *= for method_missing.
# File lib/active_record/attribute_methods/write.rb, line 65 def attribute=(attribute_name, value) write_attribute(attribute_name, value) end
write_attribute_with_type_cast(attr_name, value, should_type_cast)
click to toggle source
# File lib/active_record/attribute_methods/write.rb, line 69 def write_attribute_with_type_cast(attr_name, value, should_type_cast) attr_name = attr_name.to_s attr_name = self.class.primary_key if attr_name == 'id' && self.class.primary_key if should_type_cast @attributes.write_from_user(attr_name, value) else @attributes.write_cast_value(attr_name, value) end value end