I need to override a class method for some instances of the class
class Foo
def eigen_class
class << self
self
end
end
def self.foo
"original foo"
end
def override_foo
class << self
def self.foo
"overridden foo"
end
end
end
end
foo = Foo.new
foo.override_foo
foo.class.foo # => "original foo"
foo.eigen_class.foo # => "overridden foo"
foo2 = Foo.new
foo2.eigen_class.foo # => "original foo"
Is there a way to call overridden method without explicitly getting eigenclass?