aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/string/output_safety.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-01-28 15:00:52 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-01-28 15:00:52 -0800
commitc87fb22a061292e66d790e23eee6982c8053d270 (patch)
treea23493968b58cfa57a468a753d9d8194b50de82d /activesupport/lib/active_support/core_ext/string/output_safety.rb
parenteb33bd944d03d174ac7eac5d59fc280b35b1a3bd (diff)
downloadrails-c87fb22a061292e66d790e23eee6982c8053d270.tar.gz
rails-c87fb22a061292e66d790e23eee6982c8053d270.tar.bz2
rails-c87fb22a061292e66d790e23eee6982c8053d270.zip
make sure we play nicely when syck is activated
Diffstat (limited to 'activesupport/lib/active_support/core_ext/string/output_safety.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb
index 29d6613611..c930abc003 100644
--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb
+++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -1,6 +1,5 @@
require 'erb'
require 'active_support/core_ext/kernel/singleton_class'
-require 'active_support/core_ext/yaml'
class ERB
module Util
@@ -102,10 +101,14 @@ module ActiveSupport #:nodoc:
self
end
- unless defined?(Psych)
- def to_yaml(*args)
- to_str.to_yaml(*args)
- end
+ def encode_with(coder)
+ coder.represent_scalar nil, to_str
+ end
+
+ def to_yaml(*args)
+ return super() if defined?(YAML::ENGINE) && !YAML::ENGINE.syck?
+
+ to_str.to_yaml(*args)
end
end
end