I’m attempting to redefine existing methods with class_eval() and
nothing’s happening. Assuming my namespaces are right, is there
anything else to watch out for? The methods I’m targeting are private
instance methods. Does being private somehow shield them from
class_eval? I would have thought the answer was definitely no but the
redefinition is definitely floundering.
–
Giles B.
Blog: http://gilesbowkett.blogspot.com
Portfolio: http://www.gilesgoatboy.org
Hi –
On Thu, 16 Aug 2007, Giles B. wrote:
I’m attempting to redefine existing methods with class_eval() and
nothing’s happening. Assuming my namespaces are right, is there
anything else to watch out for? The methods I’m targeting are private
instance methods. Does being private somehow shield them from
class_eval? I would have thought the answer was definitely no but the
redefinition is definitely floundering.
Can you show an example? I’ve tried this:
class C
def x
1
end
private :x
end
C.class_eval { def x; 2; end }
p C.new.x # 2
and it works OK.
David
I’m attempting to redefine existing methods with class_eval() and
nothing’s happening. Assuming my namespaces are right, is there
Can you show an example? I’ve tried this:
It turned out that it was a namespace thing. I tested it by changing
the class_eval to do a remove_method on the methods, got method not
found errors, and fixed the namespacing.
–
Giles B.
Blog: http://gilesbowkett.blogspot.com
Portfolio: http://www.gilesgoatboy.org