On Tue, Jun 8, 2010 at 1:11 PM, Jesse A Wolfe <[email protected]> wrote:
> This is begging for a test case. I either don't understand what you're
saying Syck will do, or I can't reproduce it.

It's not really something that would be easy to meaningfully test in the
rspec paradigm, but it isn't too hard to demonstrate:

(markus) ~> irb
>> class Foo; end
=> nil
>> File.open('tmp_foo','w') { |f| f.print Foo.new.to_yaml }
=> nil
>> ^D
(markus) ~> cat tmp_foo
--- !ruby/object:Foo {}

(markus) ~> irb
>> x = YAML.load(File.read('tmp_foo'))
=> #<YAML::Object:0x3042ec @class="Foo", @ivars={}>
>> x.class
=> "Foo"
     ^^^^^ Very, very weird.

>> x.to_yaml
=> "--- !ruby/object:Foo {}\n\n"

If we reload the object in a context in which the class isn't defined we get
an object who's class is a String (instead of a Class).  This is not good
ruby, and doing much of anything with such an object gets weird fast.  But
given that such an object is in the system, the built in yaml will serialize
them out as if they had been legitimate objects (in fact, as if they had
been the original objects), which is at least better than squawking about
it, so now we do too.

-- Markus
-----------------------------------------------------------
The power of accurate observation is
commonly called cynicism by those
who have not got it.  ~George Bernard Shaw
------------------------------------------------------------

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to