Class: Object

Inherits:
BasicObject
Defined in:
lib/cucumber/core_ext/instance_exec.rb

Overview

:nodoc:

Constant Summary

Instance Method Summary (collapse)

Instance Method Details

- (Object) cucumber_instance_exec(check_arity, pseudo_method, *args, &block)

TODO: Move most of this stuff out to an InstanceExecutor class.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cucumber/core_ext/instance_exec.rb', line 12

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 = block.arity
        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