Module: ActiveRecord::AttributeMethods::Serialization

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_record/attribute_methods/serialization.rb

Defined Under Namespace

Modules: ClassMethods Classes: Attribute

Instance Method Summary collapse

Instance Method Details

#read_attribute_before_type_cast(attr_name) ⇒ Object



93
94
95
96
97
98
99
# File 'lib/active_record/attribute_methods/serialization.rb', line 93

def read_attribute_before_type_cast(attr_name)
  if serialized_attributes.include?(attr_name)
    super.unserialized_value
  else
    super
  end
end

#type_cast_attribute_for_write(column, value) ⇒ Object



85
86
87
88
89
90
91
# File 'lib/active_record/attribute_methods/serialization.rb', line 85

def type_cast_attribute_for_write(column, value)
  if column && coder = self.class.serialized_attributes[column.name]
    Attribute.new(coder, value, :unserialized)
  else
    super
  end
end