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.



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