aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-12-01 01:15:16 +0000
committerJon Leighton <j@jonathanleighton.com>2011-12-01 01:15:16 +0000
commit52eedf5e2b0b39026ab5c63c5f28fe70f88ee8db (patch)
tree20c04be8cd8bd321dc4a2894b8906d97d2d3efc5 /activerecord/lib
parent1c783c6040afd9a7ce0199e042e5c6549d0539b4 (diff)
downloadrails-52eedf5e2b0b39026ab5c63c5f28fe70f88ee8db.tar.gz
rails-52eedf5e2b0b39026ab5c63c5f28fe70f88ee8db.tar.bz2
rails-52eedf5e2b0b39026ab5c63c5f28fe70f88ee8db.zip
Add hackery to make Syck use encode_with/init_with. Fixes 1.8 after recent changes to attribute serialization.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/base.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index ee2833c5dc..76aa121ade 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1935,6 +1935,26 @@ MSG
"#<#{self.class} #{inspection}>"
end
+ # Hackery to accomodate Syck. Remove for 4.0.
+ def to_yaml(opts = {}) #:nodoc:
+ if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck?
+ super
+ else
+ coder = {}
+ encode_with(coder)
+ YAML.quick_emit(self, opts) do |out|
+ out.map(taguri, to_yaml_style) do |map|
+ coder.each { |k, v| map.add(k, v) }
+ end
+ end
+ end
+ end
+
+ # Hackery to accomodate Syck. Remove for 4.0.
+ def yaml_initialize(tag, coder) #:nodoc:
+ init_with(coder)
+ end
+
protected
def clone_attributes(reader_method = :read_attribute, attributes = {})
attribute_names.each do |name|