Florian Gilcher
4/16/2009 10:23:00 AM
>
> * Compile time metaprogramming: I don't see a huge difference to
> Ruby's
> metaprogramming here. You can do exactly the same with evaluating
> strings,
> e.g.
>
> def makeClassWithProp(name, property)
> eval %{
> class #{name}
> attr_accessor #{property}
> end
> }
> end
Actually, this is a hack already. (Warning, the parameter order is
1.9 only).
def self.makeClassWithProp(name, superclass = Object, property)
c = Class.new(superclass) {
attr_accessor property
}
const_set(name, c)
end
Is a nice and clean way to get that working. This generates a Subclass
to the Module/Class this Method is defined in.
Regards,
Florian
--
Florian Gilcher
smtp: flo@andersground.net
jabber: Skade@jabber.ccc.de
gpg: 533148E2