Sha256: 3592b17e34e0f97786f7dfce205756712fe06b5de132298d48d71d7bc00d0ee3
Contents?: true
Size: 883 Bytes
Versions: 40
Compression:
Stored size: 883 Bytes
Contents
major, minor, patch = RUBY_VERSION.split('.').map{ |v| v.to_i } if major <= 1 && minor <= 8 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 end class Object def blank? respond_to?(:empty?) ? empty? : !self end end
Version data entries
40 entries across 40 versions & 1 rubygems