Is it possible to change the binding of a procedure during invocation time?
class AllValidator
def age_validator
Proc.new {|value| self.age > value }
end
end
class Bar
attr_accessor :age
def doSomething
validator = AllValidator.new.age_validator
validator.call(25) # How to pass self as the binding?
end
end
In the code above how do I change the binding of the proc during invocation?
Is there a way to pass the binding much like the eval
function?
Note
If the example above were real, I would use mixin
/inheritence
etc. I am using the code to demonstrate my problem scenario.