diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-01 11:41:14 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-01 14:25:47 -0800 |
commit | ebe485fd8ec80a1a9b86516bc6f74bc5bbba3476 (patch) | |
tree | 690ba63f9d71107e6e54c790e9742f093d34e7be /activerecord/lib/active_record/base.rb | |
parent | ee34b4cf346975d0aef7f26ef47ee2e4f3e13c37 (diff) | |
download | rails-ebe485fd8ec80a1a9b86516bc6f74bc5bbba3476.tar.gz rails-ebe485fd8ec80a1a9b86516bc6f74bc5bbba3476.tar.bz2 rails-ebe485fd8ec80a1a9b86516bc6f74bc5bbba3476.zip |
serialize can take an arbitrary code object
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rw-r--r-- | activerecord/lib/active_record/base.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index f66b84935c..5310b55a92 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -536,7 +536,13 @@ module ActiveRecord #:nodoc: # serialize :preferences # end def serialize(attr_name, class_name = Object) - serialized_attributes[attr_name.to_s] = Coders::YAMLColumn.new(class_name) + coder = if [:load, :dump].all? { |x| class_name.respond_to?(x) } + class_name + else + Coders::YAMLColumn.new(class_name) + end + + serialized_attributes[attr_name.to_s] = coder end # Guesses the table name (in forced lower-case) based on the name of the class in the |