Skip to content
Browse files

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

  • Loading branch information...
1 parent edf116a commit b308f0d4f160307d03c5c7816d536042dc69941d @tenderlove tenderlove committed May 13, 2013
Showing with 6 additions and 12 deletions.
  1. +6 −12 activesupport/lib/active_support/callbacks.rb
View
18 activesupport/lib/active_support/callbacks.rb
@@ -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])

0 comments on commit b308f0d

Please sign in to comment.
Something went wrong with that request. Please try again.