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.
Hi --
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
···
On Thu, 16 Aug 2007, Giles Bowkett wrote:
--
* Books:
RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242\)
RUBY FOR RAILS (http://www.manning.com/black\)
* Ruby/Rails training
& consulting: Ruby Power and Light, LLC (http://www.rubypal.com)
> 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.