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

Version Path
pivotal-screw-unit-0.4.0 vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions/object.rb
pivotal-screw-unit-0.4.1 vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions/object.rb
pivotal-screw-unit-0.4.2 vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions/object.rb
pivotal-screw-unit-0.4.3 vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions/object.rb
js_spec-0.3.3 vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions/object.rb
js_spec-0.3.2 vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions/object.rb
screw-unit-0.3.3 vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions/object.rb
screw-unit-0.3.1 vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions/object.rb