D
Damphyr
I do something like the following
class Test
def Test.open
tt=Test.new
yield tt
tt.close
end
end
class DerivedTest<Test
include SomeModule
end
Obviously the following will fail
DerivedTest.open{|tt|
tt.some_module_method
}
so I moved open to DerivedTest.
Can I write a class method that instantiates the proper derived class?
I need a way to find the class of the caller and instantiate that
Am I asking for the impossible? I think not, since Ipen does this,
although the code is C - the call to rb_class_new_instance obviously
instantiates the proper class. How can I do that in pure Ruby?
Cheers,
V.-
--
http://www.braveworld.net/riva
____________________________________________________________________
http://www.freemail.gr - äùñåÜí õðçñåóßá çëåêôñïíéêïý ôá÷õäñïìåßïõ.
http://www.freemail.gr - free email service for the Greek-speaking.
class Test
def Test.open
tt=Test.new
yield tt
tt.close
end
end
class DerivedTest<Test
include SomeModule
end
Obviously the following will fail
DerivedTest.open{|tt|
tt.some_module_method
}
so I moved open to DerivedTest.
Can I write a class method that instantiates the proper derived class?
I need a way to find the class of the caller and instantiate that
Am I asking for the impossible? I think not, since Ipen does this,
although the code is C - the call to rb_class_new_instance obviously
instantiates the proper class. How can I do that in pure Ruby?
Cheers,
V.-
--
http://www.braveworld.net/riva
____________________________________________________________________
http://www.freemail.gr - äùñåÜí õðçñåóßá çëåêôñïíéêïý ôá÷õäñïìåßïõ.
http://www.freemail.gr - free email service for the Greek-speaking.