class Something
def initialize
@private_var = "private!"
end
end
object = Something.new
my_proc = proc { @private_var }
wrapped = proc { |*args, &block| object.instance_exec(*args, &my_proc) }
p wrapped.call
Y2xhc3MgU29tZXRoaW5nCiAgZGVmIGluaXRpYWxpemUKICAgIEBwcml2YXRlX3ZhciA9ICJwcml2YXRlISIKICBlbmQKZW5kCgpvYmplY3QgPSBTb21ldGhpbmcubmV3Cm15X3Byb2MgPSBwcm9jIHsgQHByaXZhdGVfdmFyIH0Kd3JhcHBlZCA9IHByb2MgeyB8KmFyZ3MsICZibG9ja3wgb2JqZWN0Lmluc3RhbmNlX2V4ZWMoKmFyZ3MsICZteV9wcm9jKSB9CgpwIHdyYXBwZWQuY2FsbA==