mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Keep the code related to serialization in Serialization module.
We should not need any `serialized_attributes` checks outside `ActiveRecord::AttributeMethods::Serialization` module.
This commit is contained in:
parent
90a1721c31
commit
410e887a44
2 changed files with 13 additions and 9 deletions
|
@ -369,14 +369,10 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def typecasted_attribute_value(name)
|
def typecasted_attribute_value(name)
|
||||||
if self.class.serialized_attributes.include?(name)
|
# FIXME: we need @attributes to be used consistently.
|
||||||
@attributes[name].serialized_value
|
# If the values stored in @attributes were already typecasted, this code
|
||||||
else
|
# could be simplified
|
||||||
# FIXME: we need @attributes to be used consistently.
|
read_attribute(name)
|
||||||
# If the values stored in @attributes were already typecasted, this code
|
|
||||||
# could be simplified
|
|
||||||
read_attribute(name)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ module ActiveRecord
|
||||||
|
|
||||||
included do
|
included do
|
||||||
# Returns a hash of all the attributes that have been specified for
|
# Returns a hash of all the attributes that have been specified for
|
||||||
# serialization as keys and their class restriction as values.
|
# serialization as keys and their class restriction as values.
|
||||||
class_attribute :serialized_attributes, instance_accessor: false
|
class_attribute :serialized_attributes, instance_accessor: false
|
||||||
self.serialized_attributes = {}
|
self.serialized_attributes = {}
|
||||||
end
|
end
|
||||||
|
@ -129,6 +129,14 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def typecasted_attribute_value(name)
|
||||||
|
if self.class.serialized_attributes.include?(name)
|
||||||
|
@attributes[name].serialized_value
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue