Sha256: 5e8091ddf5aad1ac8886ff3a7deff4dec933714afdf424bf247bde44ba4b2dd9
Contents?: true
Size: 943 Bytes
Versions: 7
Compression:
Stored size: 943 Bytes
Contents
module Dao module InstanceExec Code = lambda do unless Object.new.respond_to?(:instance_exec) 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 end def InstanceExec.included(other) other.module_eval(&Code) super end def InstanceExec.extend_object(other) other.instance_eval(&Code) super end end end
Version data entries
7 entries across 7 versions & 1 rubygems