In Ruby 1.8.7 I can do the following in order to get the subject of a binding object:
binding.eval("self")
However, in Ruby 1.8.6, the eval method is private, so I expose it like this:
class Binding
public :eval
end
Which seems to work fine, however, binding.eval("self")
returns the binding itself, not the subject of binding.
How can I get the subject of a binding in Ruby 1.8.6? The solution doesn't need to pretty - it just needs to work until we can upgrade to 1.8.7.