aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/callbacks.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-05-09 15:04:51 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-05-10 10:13:22 -0700
commitd4dcd6e41f4a7c202270e7d510434351ce333ebc (patch)
treef40d4bef66e96a1a5df466079d9e57ffde935efb /activesupport/lib/active_support/callbacks.rb
parent9b5202692065ea3ed116a0098a0312a9236e9983 (diff)
downloadrails-d4dcd6e41f4a7c202270e7d510434351ce333ebc.tar.gz
rails-d4dcd6e41f4a7c202270e7d510434351ce333ebc.tar.bz2
rails-d4dcd6e41f4a7c202270e7d510434351ce333ebc.zip
pass the run block as a normal variable to the rest of the callbacks
Diffstat (limited to 'activesupport/lib/active_support/callbacks.rb')
-rw-r--r--activesupport/lib/active_support/callbacks.rb24
1 files changed, 12 insertions, 12 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index 850e307857..511162f20f 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -176,7 +176,7 @@ module ActiveSupport
case @kind
when :before
halted_lambda = eval "lambda { |result| #{chain.config[:terminator]} }"
- lambda { |target, halted, value, &block|
+ lambda { |target, halted, value, run_block|
if !halted && user_conditions.all? { |c| c.call(target, value) }
result = user_callback.call target, value
halted = halted_lambda.call result
@@ -184,20 +184,20 @@ module ActiveSupport
target.send :halted_callback_hook, @raw_filter.inspect
end
end
- next_callback.call target, halted, value, &block
+ next_callback.call target, halted, value, run_block
}
when :after
if chain.config[:skip_after_callbacks_if_terminated]
- lambda { |target, halted, value, &block|
- target, halted, value = next_callback.call target, halted, value, &block
+ lambda { |target, halted, value, run_block|
+ target, halted, value = next_callback.call target, halted, value, run_block
if !halted && user_conditions.all? { |c| c.call(target, value) }
user_callback.call target, value
end
[target, halted, value]
}
else
- lambda { |target, halted, value, &block|
- target, halted, value = next_callback.call target, halted, value, &block
+ lambda { |target, halted, value, run_block|
+ target, halted, value = next_callback.call target, halted, value, run_block
if user_conditions.all? { |c| c.call(target, value) }
user_callback.call target, value
end
@@ -205,16 +205,16 @@ module ActiveSupport
}
end
when :around
- lambda { |target, halted, value, &block|
+ lambda { |target, halted, value, run_block|
if !halted && user_conditions.all? { |c| c.call(target, value) }
retval = nil
user_callback.call(target, value) {
- retval = next_callback.call(target, halted, value, &block)
+ retval = next_callback.call(target, halted, value, run_block)
retval.last
}
retval
else
- next_callback.call target, halted, value, &block
+ next_callback.call target, halted, value, run_block
end
}
end
@@ -334,8 +334,8 @@ module ActiveSupport
end
def compile
- callbacks = lambda { |target,halted,value,&block|
- value = !halted && (!block || block.call)
+ callbacks = lambda { |target, halted, value, run_block|
+ value = run_block.call if run_block && !halted
[target, halted, value]
}
reverse_each do |callback|
@@ -381,7 +381,7 @@ module ActiveSupport
str = object.send("_#{kind}_callbacks").compile
class_eval do
define_method(name) do |&block|
- str.call(self, false, nil, &block)[2]
+ str.call(self, false, nil, block)[2]
end
protected name
end