Sha256: 7479dae20550341c4087182aba4ace23375b0578b0ecefde4eca5587f742b018
Contents?: true
Size: 853 Bytes
Versions: 1
Compression:
Stored size: 853 Bytes
Contents
# see this;http://blog.jayfields.com/2008/02/ruby-dynamically-define-method.html # instance_exec is used for face methods if VERSION <= '1.8.6' class Object module InstanceExecHelper; end include InstanceExecHelper # instance_exec method evaluates a block of code relative to the specified object, with parameters whom come from outside the object. 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
marekj-watirloo-0.0.5 | lib/watirloo/extension/object.rb |