J
John W. Long
How do I override a class method on an object with another module? For
example:
class TestObject
def self.my_method
"override me"
end
end
module TestExtension
def my_method
"overridden by TestExtension"
end
def another_method
"another method"
end
end
TestObject.extend TestExtension
puts TestObject.my_method #=> "override me"
puts TestObject.another_method #=> "another method"
Why can't I get TestObject to use my_method from TestExtension?
example:
class TestObject
def self.my_method
"override me"
end
end
module TestExtension
def my_method
"overridden by TestExtension"
end
def another_method
"another method"
end
end
TestObject.extend TestExtension
puts TestObject.my_method #=> "override me"
puts TestObject.another_method #=> "another method"
Why can't I get TestObject to use my_method from TestExtension?