Skip to content

Commit

Permalink
just run compiled callbacks since they are cached
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed May 10, 2013
1 parent ade7d36 commit d1316bb
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions activesupport/lib/active_support/callbacks.rb
Expand Up @@ -76,8 +76,9 @@ module Callbacks
# 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
Expand Down Expand Up @@ -430,18 +431,7 @@ module ClassMethods
# 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)
Expand Down

0 comments on commit d1316bb

Please sign in to comment.