diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-04-06 18:58:19 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-04-06 18:58:19 -0300 |
commit | c539cc006179c98d418c6914ce567f657b6f1966 (patch) | |
tree | 16855e039ebab046747325dd5083c37bdba58616 /activesupport/lib | |
parent | a956ec964078ee533644fae2a99e68eda0a7c9d5 (diff) | |
parent | bdc1d329d4eea823d07cf010064bd19c07099ff3 (diff) | |
download | rails-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')
-rw-r--r-- | activesupport/lib/active_support/callbacks.rb | 16 |
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 |