aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew White <andrew.white@unboxed.co>2016-11-02 20:14:17 +0000
committerAndrew White <andrew.white@unboxed.co>2016-11-02 20:14:17 +0000
commitdb3374c428ec71fbcede2f8153c553ccbe0f1832 (patch)
tree783d9f54a87356cd540f49cf28c3292d11668f68
parent48750b434f4f96821f464c74df73e8cc22d9fb07 (diff)
downloadrails-db3374c428ec71fbcede2f8153c553ccbe0f1832.tar.gz
rails-db3374c428ec71fbcede2f8153c553ccbe0f1832.tar.bz2
rails-db3374c428ec71fbcede2f8153c553ccbe0f1832.zip
Only override to_yaml if YAML::ENGINE is defined
The Syck engine has been removed from later versions of Ruby so no need to override to_yaml for these versions.
-rw-r--r--activerecord/lib/active_record/base.rb30
1 files changed, 16 insertions, 14 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 5bd1721439..181c072211 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -648,24 +648,26 @@ module ActiveRecord #:nodoc:
"#<#{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) }
+ if YAML.const_defined?(:ENGINE)
+ # Hackery to accomodate Syck. Remove for 4.0.
+ def to_yaml(opts = {}) #:nodoc:
+ if !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
- end
- # Hackery to accomodate Syck. Remove for 4.0.
- def yaml_initialize(tag, coder) #:nodoc:
- init_with(coder)
+ # Hackery to accomodate Syck. Remove for 4.0.
+ def yaml_initialize(tag, coder) #:nodoc:
+ init_with(coder)
+ end
end
private