Skip to content

Commit 0776c97

Browse files
committed
feat: make BooleanLambdaParamable.test_lambda accept Array of args
1 parent e201b07 commit 0776c97

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

lib/kiba/extend/transforms/boolean_lambda_paramable.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,19 @@ module Transforms
2424
# instance variable on which is also set an attr_reader (private
2525
# or public is ok)
2626
#
27-
# Add the following line to the top of the `process` method:
27+
# Add the following line to the top of the `process` method if your lamba
28+
# takes a single argument:
2829
#
2930
# ~~~
3031
# test_lambda(row) unless lambda_tested
3132
# ~~~
33+
#
34+
# If your lambda takes multiple arguments, pass them in an Array in the
35+
# `test_lambda` call:
36+
#
37+
# ~~~
38+
# test_lambda([val, row]) unless lambda_tested
39+
# ~~~
3240
module BooleanLambdaParamable
3341
::BooleanLambdaParamable =
3442
Kiba::Extend::Transforms::BooleanLambdaParamable
@@ -39,8 +47,8 @@ def self.included(mod)
3947

4048
def lambda_tested = @lambda_tested
4149

42-
def test_lambda(row)
43-
result = lambda.call(row)
50+
def test_lambda(args)
51+
result = args.is_a?(Array) ? lambda.call(*args) : lambda.call(args)
4452
unless result.is_a?(TrueClass) || result.is_a?(FalseClass)
4553
fail(Kiba::Extend::BooleanReturningLambdaError)
4654
end

0 commit comments

Comments
 (0)