Permalink
Browse files

just run compiled callbacks since they are cached

  • Loading branch information...
1 parent ade7d36 commit d1316bb128b1905995ba9f3e4ff35a628b845780 @tenderlove tenderlove committed May 10, 2013
Showing with 4 additions and 14 deletions.
  1. +4 −14 activesupport/lib/active_support/callbacks.rb
@@ -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
@@ -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)

0 comments on commit d1316bb

Please sign in to comment.