Sha256: 5057bedda45b8d7a82e655cab05965aebcb6cef23f4dd6397876b5285bff93cb
Contents?: true
Size: 553 Bytes
Versions: 8
Compression:
Stored size: 553 Bytes
Contents
# From Mauricio Fernandez. class Object module InstanceExecHelper; end include InstanceExecHelper def instance_exec(*args, &block) begin old_critical, Thread.critical = Thread.critical, true n = 0 n += 1 while respond_to?(mname="__instance_exec#{n}") InstanceExecHelper.module_eval{ define_method(mname, &block) } ensure Thread.critical = old_critical end begin ret = send(mname, *args) ensure InstanceExecHelper.module_eval{ remove_method(mname) } rescue nil end ret end end
Version data entries
8 entries across 8 versions & 3 rubygems