aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-05-13 15:50:16 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-05-13 15:50:16 -0700
commitb308f0d4f160307d03c5c7816d536042dc69941d (patch)
tree5129f0d764b170c397e16256eb7d2bc80008a4f2 /activesupport
parentedf116a91b617bc941e2fcfbe60ce2f8cb92ee8a (diff)
downloadrails-b308f0d4f160307d03c5c7816d536042dc69941d.tar.gz
rails-b308f0d4f160307d03c5c7816d536042dc69941d.tar.bz2
rails-b308f0d4f160307d03c5c7816d536042dc69941d.zip
raise an argument error if the filter arity is greater than 1
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/callbacks.rb18
1 files changed, 6 insertions, 12 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index 2eec360042..fc797262d9 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -250,23 +250,17 @@ module ActiveSupport
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])