Class: Object
Overview
The math method of context needs instance_exec to pass parameters to the blocks evaluated with a modified self (pointing to a context object.) intance_exec is available in Ruby 1.9.1 and is also defined by ActiveRecord. Here we use Mauricio Fernández implementation if it is not available.
Defined Under Namespace
Modules: InstanceExecHelper
Instance Method Summary collapse
-
#instance_exec(*args, &block) ⇒ Object
!> method redefined; discarding old instance_exec.
Instance Method Details
#instance_exec(*args, &block) ⇒ Object
!> method redefined; discarding old instance_exec
1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 |
# File 'lib/flt/support.rb', line 1343 def instance_exec(*args, &block) # !> method redefined; discarding old instance_exec mname = "__instance_exec_#{Thread.current.object_id.abs}_#{object_id.abs}" InstanceExecHelper.module_eval{ define_method(mname, &block) } begin ret = send(mname, *args) ensure InstanceExecHelper.module_eval{ undef_method(mname) } rescue nil end ret end |