1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/yaml/types.rb: Likewise, pass self to YAML::quick_emit;

merged from 1.9.

* lib/yaml.rb (quick_emit): use combination of object_id and hash to
  identify repeated object references, since GC will reuse memory of
  objects during output of YAML. [ruby-Bugs-8548] [ruby-Bugs-3698];
  merged from 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2008-04-19 11:21:23 +00:00
parent 80627a281e
commit bf11d6ee76
5 changed files with 34 additions and 12 deletions

View file

@ -45,7 +45,7 @@ module YAML
class Object
def self.tag_subclasses?; false; end
def to_yaml( opts = {} )
YAML::quick_emit( object_id, opts ) do |out|
YAML::quick_emit( self, opts ) do |out|
out.map( "tag:ruby.yaml.org,2002:object:#{ @class }", to_yaml_style ) do |map|
@ivars.each do |k,v|
map.add( k, v )
@ -123,7 +123,7 @@ module YAML
true
end
def to_yaml( opts = {} )
YAML::quick_emit( self.object_id, opts ) do |out|
YAML::quick_emit( self, opts ) do |out|
out.seq( taguri, to_yaml_style ) do |seq|
self.each do |v|
seq.add( Hash[ *v ] )
@ -173,7 +173,7 @@ module YAML
true
end
def to_yaml( opts = {} )
YAML::quick_emit( self.object_id, opts ) do |out|
YAML::quick_emit( self, opts ) do |out|
out.seq( taguri, to_yaml_style ) do |seq|
self.each do |v|
seq.add( Hash[ *v ] )