summaryrefslogtreecommitdiff
path: root/ext/psych/lib/psych/visitors
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-16 20:27:51 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-16 20:27:51 +0000
commit2db7b7f3fe7de2b518d46ea11c26875f86d26136 (patch)
tree063260cf9c6da1074cbf3d7413b173206b5cb8f5 /ext/psych/lib/psych/visitors
parent039219b2c978641d96fe28ba451148b0425ffd4e (diff)
* ext/psych/lib/psych/coder.rb (scalar): supporting deprecated methods
* ext/psych/lib/psych/deprecated.rb: supporting deprecated to_yaml_properties method git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/psych/lib/psych/visitors')
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb21
1 files changed, 15 insertions, 6 deletions
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index 3cbb695bce..4f990a73d6 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/lib/psych/visitors/yaml_tree.rb
@@ -182,9 +182,7 @@ module Psych
plain = !quote
end
- ivars = o.respond_to?(:to_yaml_properties) ?
- o.to_yaml_properties :
- o.instance_variables
+ ivars = find_ivars o
scalar = create_scalar str, nil, tag, plain, quote
@@ -251,6 +249,19 @@ module Psych
end
private
+ # FIXME: remove this method once "to_yaml_properties" is removed
+ def find_ivars target
+ m = target.method(:to_yaml_properties)
+ unless m.source_location.first.start_with?(Psych::DEPRECATED)
+ if $VERBOSE
+ warn "to_yaml_properties is deprecated, please implement \"encode_with(coder)\""
+ end
+ return target.to_yaml_properties
+ end
+
+ target.instance_variables
+ end
+
def append o
@stack.last.children << o
o
@@ -295,9 +306,7 @@ module Psych
end
def dump_ivars target, map
- ivars = target.respond_to?(:to_yaml_properties) ?
- target.to_yaml_properties :
- target.instance_variables
+ ivars = find_ivars target
ivars.each do |iv|
map.children << create_scalar("#{iv.to_s.sub(/^@/, '')}")