I am trying to call a proc on a class but access instance methods from it with an inherited class. I think some mock code will make more sense :)
class Bar
def self.foo &block
@foo ||= block
end
def foo; self.class.foo.call(); end
def bar; 'bar'; end
end
class Foo < Bar
foo do
bar
end
end
Foo.new.foo
# NameError: undefined local variable or method `bar' for Foo:Class
I want to be able to access the bar instance method on the Bar class. The reason for calling the foo class method with a block from the inherited class is part of the DSL requirement, but any suggestions for a better design would be appreciated.
new.baror makingbara class method not good?