B
blogger
I have an app with source code I really don't want to touch, which has
an object method I want to be able to overwrite in a certain task.
(No need to restore the function.) My current technique is as
follows:
In the application:
class C
def m
puts "barf"
end
end
In my module file:
module M
def self.included(mod)
mod.module_eval <<-EOF
def m
puts "c001c0de"
end
EOF
end
end
In the rake file:
C:send
include, M)
Now I REALLY don't like module_eval(string). Is there a preferred
method to achieve this result?
an object method I want to be able to overwrite in a certain task.
(No need to restore the function.) My current technique is as
follows:
In the application:
class C
def m
puts "barf"
end
end
In my module file:
module M
def self.included(mod)
mod.module_eval <<-EOF
def m
puts "c001c0de"
end
EOF
end
end
In the rake file:
C:send
Now I REALLY don't like module_eval(string). Is there a preferred
method to achieve this result?