Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #8164 from nikitug/keep_serialization_in_its_module

Keep the code related to serialization in Serialization module.
  • Loading branch information...
commit a002442fbce098ce5ae9597784ab2755bdad111a 2 parents 90a1721 + 410e887
@carlosantoniodasilva carlosantoniodasilva authored
View
12 activerecord/lib/active_record/attribute_methods.rb
@@ -369,14 +369,10 @@ def pk_attribute?(name)
end
def typecasted_attribute_value(name)
- if self.class.serialized_attributes.include?(name)
- @attributes[name].serialized_value
- else
- # FIXME: we need @attributes to be used consistently.
- # If the values stored in @attributes were already typecasted, this code
- # could be simplified
- read_attribute(name)
- end
+ # FIXME: we need @attributes to be used consistently.
+ # If the values stored in @attributes were already typecasted, this code
+ # could be simplified
+ read_attribute(name)
end
end
end
View
10 activerecord/lib/active_record/attribute_methods/serialization.rb
@@ -5,7 +5,7 @@ module Serialization
included do
# 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
self.serialized_attributes = {}
end
@@ -129,6 +129,14 @@ def attributes_before_type_cast
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
Please sign in to comment.
Something went wrong with that request. Please try again.