Permalink
Browse files

Eliminate the need to check for superclass changes to the callback st…

…ack each time through the callbacks
  • Loading branch information...
1 parent a87b627 commit 220603ee70d1655cf97a1e9f09fbc5d019c99856 @wycats wycats committed Jun 4, 2010
Showing with 6 additions and 3 deletions.
  1. +6 −3 activesupport/lib/active_support/callbacks.rb
@@ -390,9 +390,12 @@ def __define_runner(symbol) #:nodoc:
undef_method "_run_#{symbol}_callbacks" if method_defined?("_run_#{symbol}_callbacks")
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def _run_#{symbol}_callbacks(key = nil, &blk)
- if self.class.send("_update_#{symbol}_superclass_callbacks")
- self.class.__define_runner(#{symbol.inspect})
- return _run_#{symbol}_callbacks(key, &blk)
+ @_initialized_#{symbol}_callbacks ||= begin
+ if self.class.send("_update_#{symbol}_superclass_callbacks")
+ self.class.__define_runner(#{symbol.inspect})
+ return _run_#{symbol}_callbacks(key, &blk)
+ end
+ true
end
if key

0 comments on commit 220603e

Please sign in to comment.