Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/call_center/core_ext/object_instance_exec.rb
Overview
From Active Support
Instance Method Summary collapse
Instance Method Details
#instance_exec(*args, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/call_center/core_ext/object_instance_exec.rb', line 4 def instance_exec(*args, &block) begin old_critical, Thread.critical = Thread.critical, true n = 0 n += 1 while respond_to?(method_name = "__instance_exec#{n}") InstanceExecMethods.module_eval { define_method(method_name, &block) } ensure Thread.critical = old_critical end begin send(method_name, *args) ensure InstanceExecMethods.module_eval { remove_method(method_name) } rescue nil end end |