Object Scope Bindings
Some time ago, I saw a ruby code that looked something like
where foo was some method of obj
. I could see that inside of the block the
scoping rules were respect to the obj
. I wondered for a long time how this
was done so I decided to figure it out. It turns out that it’s just a simple
use of instance_eval
. You can implement it as such:
You can see something like this from RSpec or rake.