提交 b308f0d4 编写于 作者: A Aaron Patterson

raise an argument error if the filter arity is greater than 1

上级 edf116a9
......@@ -250,23 +250,17 @@ def invert_lambda(l)
def make_lambda(filter)
case filter
when Symbol
lambda { |target, value, &blk| target.send filter, &blk }
lambda { |target, _, &blk| target.send filter, &blk }
when String
l = eval "lambda { |value| #{filter} }"
lambda { |target,value| target.instance_exec(value, &l) }
lambda { |target, value| target.instance_exec(value, &l) }
when ::Proc
if filter.arity <= 0
return lambda { |target, _| target.instance_exec(&filter) }
end
raise ArgumentError if filter.arity > 1
if filter.arity == 1
lambda { |target, _|
target.instance_exec(target, &filter)
}
if filter.arity <= 0
lambda { |target, _| target.instance_exec(&filter) }
else
lambda { |target, _|
target.instance_exec target, ::Proc.new, &filter
}
lambda { |target, _| target.instance_exec(target, &filter) }
end
else
scopes = Array(chain_config[:scope])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册