diff options
author | Guo Xiang Tan <tgx_world@hotmail.com> | 2015-03-22 10:43:34 +0800 |
---|---|---|
committer | Guo Xiang Tan <tgx_world@hotmail.com> | 2015-03-22 11:21:02 +0800 |
commit | bdc1d329d4eea823d07cf010064bd19c07099ff3 (patch) | |
tree | ca60c74fd711b4b22c688b566734d216d5d8807b /activesupport/lib/active_support | |
parent | 2271f7db17b728234abc2ca66e6cf9a4c55d8e84 (diff) | |
download | rails-bdc1d329d4eea823d07cf010064bd19c07099ff3.tar.gz rails-bdc1d329d4eea823d07cf010064bd19c07099ff3.tar.bz2 rails-bdc1d329d4eea823d07cf010064bd19c07099ff3.zip |
Revert "Reduce allocations when running AR callbacks."
This reverts commit 796cab45561fce268aa74e6587cdb9cae3bb243e.
Diffstat (limited to 'activesupport/lib/active_support')
-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 37f9494272..c9dcb6b28b 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -79,14 +79,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) @@ -94,6 +90,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. @@ -797,12 +795,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 |