If these calls can not change:
value = rule(condition: lambda {@something > 100})
value.act(120)
Try instance_exec
:
def rule(condition: nil)
t = Object.new
t.class.module_eval do
attr_accessor :condition
def act(something)
@something = something
if(instance_exec &condition)
"SUCCESS"
else
"FAILURE"
end
end
end
t.condition = condition
t
end
It invokes the condition in t
's context.