aboutsummaryrefslogtreecommitdiffstats
path: root/ext/psych
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-09 20:33:10 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-09 20:33:10 +0000
commit186e5758278f40e2415b5b1c7a4251900e9fe3b4 (patch)
tree96b6b665f49d992121dd2f10afaec76c777c2865 /ext/psych
parent052f204dcbb3d02509a47e8bd559a444a3f81160 (diff)
downloadruby-186e5758278f40e2415b5b1c7a4251900e9fe3b4.tar.gz
* ext/psych/lib/psych/deprecated.rb: implementing Psych.quick_emit and
adding deprecation warnings. * ext/psych/lib/psych/visitors/to_ruby.rb: supporting deprecated yaml_initialize api. * ext/psych/lib/psych/visitors/yaml_tree.rb: supporting deprecated to_yaml api. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/psych')
-rw-r--r--ext/psych/lib/psych/deprecated.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/ext/psych/lib/psych/deprecated.rb b/ext/psych/lib/psych/deprecated.rb
new file mode 100644
index 0000000000..5a96e91154
--- /dev/null
+++ b/ext/psych/lib/psych/deprecated.rb
@@ -0,0 +1,19 @@
+module Psych
+ module DeprecatedMethods # :nodoc:
+ attr_accessor :taguri
+ attr_accessor :to_yaml_style
+ end
+
+ def self.quick_emit thing, opts = {}, &block # :nodoc:
+ warn "#{caller[0]}: YAML.quick_emit is deprecated" if $VERBOSE && !caller[0].start_with?(File.dirname(__FILE__))
+ target = eval 'self', block.binding
+ target.extend DeprecatedMethods
+ metaclass = class << target; self; end
+ metaclass.send(:define_method, :encode_with) do |coder|
+ target.taguri = coder.tag
+ target.to_yaml_style = coder.style
+ block.call coder
+ end
+ target.psych_to_yaml unless opts[:nodump]
+ end
+end