Skip to content

Commit

Permalink
Merge pull request #4189 from bogdan/non_keyed_callbacks
Browse files Browse the repository at this point in the history
AS::Callbacks: improved __define_runner performance
  • Loading branch information
josevalim committed Dec 25, 2011
2 parents 748725e + 7e75dc5 commit e33c946
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions activesupport/lib/active_support/callbacks.rb
Expand Up @@ -381,9 +381,8 @@ def __define_runner(symbol) #:nodoc:
name = __callback_runner_name(nil, symbol) name = __callback_runner_name(nil, symbol)
undef_method(name) if method_defined?(name) undef_method(name) if method_defined?(name)


silence_warnings do runner_method = "_run_#{symbol}_callbacks"
runner_method = "_run_#{symbol}_callbacks" unless private_method_defined?(runner_method)
undef_method runner_method if method_defined?(runner_method)
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{runner_method}(key = nil, &blk) def #{runner_method}(key = nil, &blk)
self.class.__run_callback(key, :#{symbol}, self, &blk) self.class.__run_callback(key, :#{symbol}, self, &blk)
Expand Down

0 comments on commit e33c946

Please sign in to comment.