--3V7upXqbjpZ4EhLz
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

David Garamond (lists / zara.6.isreserved.com) wrote:

> Remembering that all classes are instances of the Class class, is this 
> possible? I want to create some class named, say C1, which is empty (or 
> perhaps with one or two class instance vars) by loading a YAML document. 
> I can't seem to create instances of Class class in YAML, while I can 
> easily do this in irb:

irb(main):002:0> 5.to_yaml
=> "--- 5"
irb(main):003:0> Class.to_yaml
ArgumentError: can't dump anonymous class Class
        from /usr/local/lib/ruby/1.8/yaml/rubytypes.rb:8:in `to_yaml'
        from (irb):3
irb(main):004:0> class Foo; end
=> nil
irb(main):005:0> Foo.to_yaml
ArgumentError: can't dump anonymous class Class
        from /usr/local/lib/ruby/1.8/yaml/rubytypes.rb:8:in `to_yaml'
        from (irb):5

Does not appear possible to do with Yaml, but you can with Marshal:

irb(main):007:0> Marshal.dump(Foo)
=> "\004\010c\010Foo"


-- 
Eric Hodel - drbrain / segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E  7C11 332A 551C 796C 9F04


--3V7upXqbjpZ4EhLz
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQE/cJrDMypVHHlsnwQRAkvJAJ9N6nrkRwQF1ezrs7ZDliS7YBHt9gCgzVLx
DWyJ7VxG/eqRXHg/yvhmMhMIg
-----END PGP SIGNATURE-----

--3V7upXqbjpZ4EhLz--