From 8dfd1b10016855187ade94f36d592b0319e2b226 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 29 Mar 2011 20:41:03 -0700 Subject: pulling in changes from ruby core --- lib/psych/visitors/yaml_tree.rb | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb index 719720a..84ebc90 100644 --- a/lib/psych/visitors/yaml_tree.rb +++ b/lib/psych/visitors/yaml_tree.rb @@ -79,15 +79,20 @@ module Psych end if target.respond_to?(:to_yaml) - loc = target.method(:to_yaml).source_location.first - if loc !~ /(syck\/rubytypes.rb|psych\/core_ext.rb)/ - unless target.respond_to?(:encode_with) - if $VERBOSE - warn "implementing to_yaml is deprecated, please implement \"encode_with\"" + begin + loc = target.method(:to_yaml).source_location.first + if loc !~ /(syck\/rubytypes.rb|psych\/core_ext.rb)/ + unless target.respond_to?(:encode_with) + if $VERBOSE + warn "implementing to_yaml is deprecated, please implement \"encode_with\"" + end + + target.to_yaml(:nodump => true) end - - target.to_yaml(:nodump => true) end + rescue + # public_method or source_location might be overridden, + # and it's OK to skip it since it's only to emit a warning end end @@ -300,12 +305,17 @@ module Psych # FIXME: remove this method once "to_yaml_properties" is removed def find_ivars target - loc = target.method(:to_yaml_properties).source_location.first - unless loc.start_with?(Psych::DEPRECATED) || loc.end_with?('rubytypes.rb') - if $VERBOSE - warn "#{loc}: to_yaml_properties is deprecated, please implement \"encode_with(coder)\"" + begin + loc = target.method(:to_yaml_properties).source_location.first + unless loc.start_with?(Psych::DEPRECATED) || loc.end_with?('rubytypes.rb') + if $VERBOSE + warn "#{loc}: to_yaml_properties is deprecated, please implement \"encode_with(coder)\"" + end + return target.to_yaml_properties end - return target.to_yaml_properties + rescue + # public_method or source_location might be overridden, + # and it's OK to skip it since it's only to emit a warning. end target.instance_variables -- cgit v1.2.3