fork download
  1. class Something
  2. def initialize
  3. @private_var = "private!"
  4. end
  5. end
  6.  
  7. object = Something.new
  8. my_proc = proc { @private_var }
  9. wrapped = proc { |*args, &block| object.instance_exec(*args, &my_proc) }
  10.  
  11. p wrapped.call
Success #stdin #stdout 0.02s 7420KB
stdin
Standard input is empty
stdout
"private!"