From d1316bb128b1905995ba9f3e4ff35a628b845780 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 10 May 2013 11:05:47 -0700 Subject: just run compiled callbacks since they are cached --- activesupport/lib/active_support/callbacks.rb | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 32234431a6..4b5c1ed538 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -76,8 +76,9 @@ module ActiveSupport # save # end def run_callbacks(kind, &block) - runner_name = self.class.__define_callbacks(kind, self) - send(runner_name, &block) + runner = self.class.__define_callbacks(kind, self) + e = Filters::Environment.new(self, false, nil, block) + runner.call(e).value end private @@ -430,18 +431,7 @@ module ActiveSupport # if it was not yet defined. # This generated method plays caching role. def __define_callbacks(kind, object) #:nodoc: - name = __callback_runner_name(kind) - unless object.respond_to?(name, true) - filter_chain = object.send("_#{kind}_callbacks").compile - class_eval do - define_method(name) do |&block| - e = Filters::Environment.new(self, false, nil, block) - filter_chain.call(e).value - end - protected name - end - end - name + object.send("_#{kind}_callbacks").compile end def __reset_runner(symbol) -- cgit v1.2.3