aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-04-06 18:58:19 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-04-06 18:58:19 -0300
commitc539cc006179c98d418c6914ce567f657b6f1966 (patch)
tree16855e039ebab046747325dd5083c37bdba58616 /activesupport/lib/active_support
parenta956ec964078ee533644fae2a99e68eda0a7c9d5 (diff)
parentbdc1d329d4eea823d07cf010064bd19c07099ff3 (diff)
downloadrails-c539cc006179c98d418c6914ce567f657b6f1966.tar.gz
rails-c539cc006179c98d418c6914ce567f657b6f1966.tar.bz2
rails-c539cc006179c98d418c6914ce567f657b6f1966.zip
Merge pull request #19448 from tgxworld/fix_activesupport_callbacks_clash_on_run
Fix AS::Callbacks raising an error when `:run` callback is defined.
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/callbacks.rb16
1 files changed, 4 insertions, 12 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index 9cf09ab266..53039dbf8b 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -80,14 +80,10 @@ module ActiveSupport
# save
# end
def run_callbacks(kind, &block)
- send "_run_#{kind}_callbacks", &block
- end
-
- private
+ callbacks = send("_#{kind}_callbacks")
- def _run_callbacks(callbacks, &block)
if callbacks.empty?
- block.call if block
+ yield if block_given?
else
runner = callbacks.compile
e = Filters::Environment.new(self, false, nil, block)
@@ -95,6 +91,8 @@ module ActiveSupport
end
end
+ private
+
# A hook invoked every time a before callback is halted.
# This can be overridden in AS::Callback implementors in order
# to provide better debugging/logging.
@@ -800,12 +798,6 @@ module ActiveSupport
names.each do |name|
class_attribute "_#{name}_callbacks"
set_callbacks name, CallbackChain.new(name, options)
-
- module_eval <<-RUBY, __FILE__, __LINE__ + 1
- def _run_#{name}_callbacks(&block)
- _run_callbacks(_#{name}_callbacks, &block)
- end
- RUBY
end
end