Skip to content

Commit

Permalink
Refactor, simplyfying code cucumber#371
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwynne committed Apr 22, 2013
1 parent 86224ba commit 396c20b
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/cucumber/core_ext/instance_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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 = block.arity
ari = ari < 0 ? (ari.abs-1).to_s+"+" : ari
s1 = ari == 1 ? "" : "s"
s2 = args.length == 1 ? "" : "s"
Expand All @@ -29,15 +29,11 @@ def cucumber_instance_exec(check_arity, pseudo_method, *args, &block)

private

def cucumber_arity(block)
# TODO: inline method
block.arity
end

def cucumber_compatible_arity?(args, block)
ari = cucumber_arity(block)
len = args.length
return true if ari == len or ari < 0 && len >= ari.abs-1
return true if block.arity == args.length
if block.arity < 0
return true if args.length >= (block.arity.abs - 1)
end
false
end

Expand Down

0 comments on commit 396c20b

Please sign in to comment.