diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-01 11:07:02 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-01 14:25:46 -0800 |
commit | a6cf6ec98b58dc2a7d0586ccb6ef970d93f0bafc (patch) | |
tree | f3999f8e7aca92110819970198e4e6fca3baf37d /activerecord/lib/active_record/base.rb | |
parent | 69600a9f97d2f678972500d8a741edc745833718 (diff) | |
download | rails-a6cf6ec98b58dc2a7d0586ccb6ef970d93f0bafc.tar.gz rails-a6cf6ec98b58dc2a7d0586ccb6ef970d93f0bafc.tar.bz2 rails-a6cf6ec98b58dc2a7d0586ccb6ef970d93f0bafc.zip |
move the coders to the serialized_attributes hash
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rw-r--r-- | activerecord/lib/active_record/base.rb | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 1e762a287d..42226f83ea 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -536,7 +536,7 @@ module ActiveRecord #:nodoc: # serialize :preferences # end def serialize(attr_name, class_name = Object) - serialized_attributes[attr_name.to_s] = class_name + serialized_attributes[attr_name.to_s] = Coders::YAMLColumn.new(class_name) end # Guesses the table name (in forced lower-case) based on the name of the class in the @@ -1738,8 +1738,9 @@ MSG if include_readonly_attributes || (!include_readonly_attributes && !self.class.readonly_attributes.include?(name)) value = read_attribute(name) - if !value.nil? && self.class.serialized_attributes.key?(name) - value = YAML.dump value + coder = self.class.serialized_attributes[name] + if !value.nil? && coder + value = coder.dump value end attrs[self.class.arel_table[name]] = value end @@ -1865,11 +1866,6 @@ MSG end end - def object_from_yaml(string) - return string unless string.is_a?(String) && string =~ /^---/ - YAML::load(string) rescue string - end - def populate_with_current_scope_attributes if scope = self.class.send(:current_scoped_methods) create_with = scope.scope_for_create |