Skip to content

Commit

Permalink
making sure psych defines to_yaml on object
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Mar 28, 2010
1 parent b051cf8 commit d99e787
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
6 changes: 6 additions & 0 deletions lib/psych/core_ext.rb
Expand Up @@ -3,6 +3,12 @@ def self.yaml_tag url
Psych.add_tag(url, self)
end

# FIXME: rename this to "to_yaml" when syck is removed

###
# call-seq: to_yaml
#
# Convert an object to YAML
def psych_to_yaml options = {}
Psych.dump self, options
end
Expand Down
14 changes: 6 additions & 8 deletions test/psych/helper.rb
Expand Up @@ -54,12 +54,10 @@ def mktime( year, mon, day, hour, min, sec, usec, zone = "Z" )
end
end

o = Object.new
if o.respond_to?(:to_yaml)
if o.method(:to_yaml).source_location.first !~ /psych/
Object.send :alias_method, :old_to_yaml, :to_yaml
Object.send :remove_method, :to_yaml
end
end

require 'psych'

# FIXME: remove this when syck is removed
o = Object.new
a = o.method(:psych_to_yaml)
b = o.method(:to_yaml)
raise "psych should define to_yaml" unless a == b
17 changes: 0 additions & 17 deletions test/psych/test_object_to_yaml.rb

This file was deleted.

0 comments on commit d99e787

Please sign in to comment.