Skip to content

Commit

Permalink
psych/visitors/yaml_tree.rb: skip warning when excpt as last commit says
Browse files Browse the repository at this point in the history
  • Loading branch information
godfat committed Feb 15, 2011
1 parent f4e0e8f commit c7a6cf9
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions ext/psych/lib/psych/visitors/yaml_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,20 @@ def accept target
end

if target.respond_to?(:to_yaml)
loc = target.public_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.public_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

Expand Down Expand Up @@ -297,12 +302,17 @@ def format_time time

# FIXME: remove this method once "to_yaml_properties" is removed
def find_ivars target
loc = target.public_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.public_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
Expand Down

0 comments on commit c7a6cf9

Please sign in to comment.