aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-06-05 17:30:11 +0900
committerAaron Patterson <aaron.patterson@gmail.com>2013-06-05 17:30:11 +0900
commit04347540510aff4ce7df2abafcc517de338bd668 (patch)
tree76d395d9cbbacc39f2c532993a9a492dd7bfc5e2 /activerecord
parent00ce4b4aa176ff5bd07d01d1fae5d7ee27b53e8f (diff)
downloadrails-04347540510aff4ce7df2abafcc517de338bd668.tar.gz
rails-04347540510aff4ce7df2abafcc517de338bd668.tar.bz2
rails-04347540510aff4ce7df2abafcc517de338bd668.zip
the typecast value should be passed to the serializer. fixes #10830
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/attribute_methods/serialization.rb10
-rw-r--r--activerecord/test/cases/adapters/postgresql/bytea_test.rb1
2 files changed, 5 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/serialization.rb b/activerecord/lib/active_record/attribute_methods/serialization.rb
index d326ef7c22..9caf73e627 100644
--- a/activerecord/lib/active_record/attribute_methods/serialization.rb
+++ b/activerecord/lib/active_record/attribute_methods/serialization.rb
@@ -56,7 +56,7 @@ module ActiveRecord
end
def type_cast(value)
- value.unserialized_value
+ value.unserialized_value @column.type_cast value.value
end
def type
@@ -65,17 +65,17 @@ module ActiveRecord
end
class Attribute < Struct.new(:coder, :value, :state) # :nodoc:
- def unserialized_value
- state == :serialized ? unserialize : value
+ def unserialized_value(v = value)
+ state == :serialized ? unserialize(v) : value
end
def serialized_value
state == :unserialized ? serialize : value
end
- def unserialize
+ def unserialize(v)
self.state = :unserialized
- self.value = coder.load(value)
+ self.value = coder.load(v)
end
def serialize
diff --git a/activerecord/test/cases/adapters/postgresql/bytea_test.rb b/activerecord/test/cases/adapters/postgresql/bytea_test.rb
index f3990980eb..489efac932 100644
--- a/activerecord/test/cases/adapters/postgresql/bytea_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/bytea_test.rb
@@ -92,7 +92,6 @@ class PostgresqlByteaTest < ActiveRecord::TestCase
end
def test_serialize
- serializer = Serializer.new
klass = Class.new(ByteaDataType) {
serialize :serialized, Serializer.new
}