On Sun, Mar 27, 2011 at 10:38 PM, Vicente Bosch Campos <vbosch / gmail.com> wrote:
> I think this Constant "Magic" only works for classes as Robert has indicated. At least I have not seen anything on google or my
> bookshelf to do it.
>
> I personally would not use it, its an exception of how the operator works, and forces people to delve into how your object works which
> can be considered as not very clean.

But it allows some very nice things, like having ways of creating
classes, assign them to constants and have them work as a regularly
defined class very easily:

ruby-1.8.7-p334 :001 > TestClass = Struct.new :id
 => TestClass
ruby-1.8.7-p334 :004 > TestClass.name
 => "TestClass"

(Struct.new returns a class)

Jesus.