From dbee8c32588083f54857e01b20479229b2f49498 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 14 May 2013 14:02:33 -0700 Subject: fixing arity2 test --- activesupport/lib/active_support/callbacks.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index ab3bb23e88..d2a545b6d4 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -109,10 +109,10 @@ module ActiveSupport class Before def self.build(next_callback, user_callback, user_conditions, chain_config, filter) if chain_config.key?(:terminator) && user_conditions.any? - halted_lambda = eval "lambda { |result| #{chain_config[:terminator]} }" + halted_lambda = class_eval "lambda { |result| #{chain_config[:terminator]} }", __FILE__, __LINE__ halting_and_conditional(next_callback, user_callback, user_conditions, halted_lambda, filter) elsif chain_config.key? :terminator - halted_lambda = eval "lambda { |result| #{chain_config[:terminator]} }" + halted_lambda = class_eval "lambda { |result| #{chain_config[:terminator]} }", __FILE__, __LINE__ halting(next_callback, user_callback, halted_lambda, filter) elsif user_conditions.any? conditional(next_callback, user_callback, user_conditions) @@ -431,7 +431,12 @@ module ActiveSupport l = eval "lambda { |value| #{filter} }" lambda { |target, value| target.instance_exec(value, &l) } when ::Proc - raise ArgumentError if filter.arity > 1 + if filter.arity > 1 + return lambda { |target, _, &block| + raise ArgumentError unless block + target.instance_exec(target, block, &filter) + } + end if filter.arity <= 0 lambda { |target, _| target.instance_exec(&filter) } -- cgit v1.2.3