Class: Object
- Inherits:
- BasicObject
- Includes:
- InstanceExecHelper
- Defined in:
- lib/cucumber/core_ext/instance_exec.rb
Overview
:nodoc:
Defined Under Namespace
Modules: InstanceExecHelper
Instance Method Summary collapse
-
#cucumber_instance_exec(check_arity, pseudo_method, *args, &block) ⇒ Object
TODO: Move most of this stuff out to an InstanceExecutor class.
- #instance_exec(*args, &block) ⇒ Object
Instance Method Details
#cucumber_instance_exec(check_arity, pseudo_method, *args, &block) ⇒ Object
TODO: Move most of this stuff out to an InstanceExecutor class.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cucumber/core_ext/instance_exec.rb', line 35 def cucumber_instance_exec(check_arity, pseudo_method, *args, &block) cucumber_run_with_backtrace_filtering(pseudo_method) do if check_arity && !cucumber_compatible_arity?(args, block) instance_exec do ari = cucumber_arity(block) ari = ari < 0 ? (ari.abs-1).to_s+"+" : ari s1 = ari == 1 ? "" : "s" s2 = args.length == 1 ? "" : "s" raise Cucumber::ArityMismatchError.new( "Your block takes #{ari} argument#{s1}, but the Regexp matched #{args.length} argument#{s2}." ) end else instance_exec(*args, &block) end end end |
#instance_exec(*args, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cucumber/core_ext/instance_exec.rb', line 16 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 |