M
Marcos
This seems like it should work:
class Parent
class << self
def real_method() "Parent" end
alias :fake_method :real_method
end
end
class Child < Parent
def real_method() "Child" end
end
But it doesn't:
Child.fake_method # ==> returns "Parent" instead of "Child"
If I replace the alias with a real method definition, e.g.
def fake_method() real_method end
then it works the way I expect (Child.fake_method returns "Child").
So what is it about "alias" that bypasses the override? Do I have to
replace my aliases with extra wrapper methods to get the behavior I'm
looking for?
class Parent
class << self
def real_method() "Parent" end
alias :fake_method :real_method
end
end
class Child < Parent
def real_method() "Child" end
end
But it doesn't:
Child.fake_method # ==> returns "Parent" instead of "Child"
If I replace the alias with a real method definition, e.g.
def fake_method() real_method end
then it works the way I expect (Child.fake_method returns "Child").
So what is it about "alias" that bypasses the override? Do I have to
replace my aliases with extra wrapper methods to get the behavior I'm
looking for?