hello,
is this a proper way to do it:
name = 'MyModule'
o = Object.new
o.extend(Module.const_get(name))
are there better ways?
this will fail for "ModuleA::ModuleB". for that you need something like:
#
# creates a class by class name
#
def klass_stamp(hierachy, *a, &b)
#--{{{
ancestors = hierachy.split(%r/::/)
parent = Object
while((child = ancestors.shift))
klass = parent.const_get child
parent = klass
end
klass::new(*a, &b)
#--}}}
end
this will work for
m = klass_stamp "A::B::C::Module"
o = Object::new
o.extend m
it's in alib.rb btw.
hth.
-a
--
===============================================================================
| ara [dot] t [dot] howard [at] noaa [dot] gov
| all happiness comes from the desire for others to be happy. all misery
| comes from the desire for oneself to be happy.
| -- bodhicaryavatara
===============================================================================