Hi all,
I would like to redefine a mofule function in a method, play with my
module
and redefine this function with original one. I can’t find a way to do
this
because I can’t open a module in a method.
Hi all,
I would like to redefine a mofule function in a method, play with my
module
and redefine this function with original one. I can’t find a way to do
this
because I can’t open a module in a method.
On 12/4/06, Michel C. [email protected] wrote:
Hi all,
I would like to redefine a mofule function in a method, play with my module
and redefine this function with original one. I can’t find a way to do this
because I can’t open a module in a method.
Not clear if you mean something like this:
module M
def m1; 1; end
end
class C1
include M
end
p C1.new.m1
class C2
include M
def redef
M.module_eval do
define_method(:m1) {2}
end
end
end
C2.new.redef
p C1.new.m1
/Robert
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs