Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/tropo-webapi-ruby/object_patch.rb
Overview
Borrowed from here: eigenclass.org/hiki.rb?instance_exec
Instance Method Summary collapse
Instance Method Details
#instance_exec(*args, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/tropo-webapi-ruby/object_patch.rb', line 3 def instance_exec(*args, &block) mname = "__instance_exec_#{Thread.current.object_id.abs}" class << self; self end.class_eval{ define_method(mname, &block) } begin ret = send(mname, *args) ensure class << self; self end.class_eval{ undef_method(mname) } rescue nil end ret end |