YAML not dumping classname constants

H

haldane

Hi,

Is there any way that YAML can be made to be able to dump classname
constants? It would be most useful, and would mean I could use nice
readable YAML instead of Marshal.

Example:

irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> x = String
=> String
irb(main):003:0> Marshal.dump(x)
=> "\004\010c\vString"
irb(main):004:0> x.to_yaml
TypeError: can't dump anonymous class Class
from c:/ruby/lib/ruby/1.8/yaml/rubytypes.rb:9:in `to_yaml'
from (irb):4
irb(main):005:0>


Stephen Sykes
 
J

Joel VanderWerf

haldane said:
Hi,

Is there any way that YAML can be made to be able to dump classname
constants? It would be most useful, and would mean I could use nice
readable YAML instead of Marshal.

Example:

irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> x = String
=> String
irb(main):003:0> Marshal.dump(x)
=> "\004\010c\vString"
irb(main):004:0> x.to_yaml
TypeError: can't dump anonymous class Class
from c:/ruby/lib/ruby/1.8/yaml/rubytypes.rb:9:in `to_yaml'
from (irb):4
irb(main):005:0>


Stephen Sykes

There's a quick fix at:

http://ruby-talk.org/95432

I use this all the time. Maybe _why would be willing to adopt it as a
standard feature?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top