Skip to content
Browse files

AS::Callbacks: remove __define_runner

  • Loading branch information...
1 parent 5b8d270 commit 40c8aa706adbb60ff9d289016fb9020d48969fea @bogdan bogdan committed with lest
Showing with 3 additions and 16 deletions.
  1. +3 −16 activesupport/lib/active_support/callbacks.rb
View
19 activesupport/lib/active_support/callbacks.rb
@@ -77,8 +77,8 @@ module Callbacks
# save
# end
#
- def run_callbacks(kind, *args, &block)
- send("_run_#{kind}_callbacks", *args, &block)
+ def run_callbacks(kind, key = nil, &block)
+ self.class.__run_callbacks(key, kind, self, &block)
end
private
@@ -376,24 +376,12 @@ def compile(key=nil, object=nil)
end
module ClassMethods
- # Generate the internal runner method called by +run_callbacks+.
- def __define_runner(symbol) #:nodoc:
- runner_method = "_run_#{symbol}_callbacks"
- unless private_method_defined?(runner_method)
- class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
- def #{runner_method}(key = nil, &blk)
- self.class.__run_callback(key, :#{symbol}, self, &blk)
- end
- private :#{runner_method}
- RUBY_EVAL
- end
- end
# This method calls the callback method for the given key.
# If this called first time it creates a new callback method for the key,
# calculating which callbacks can be omitted because of per_key conditions.
#
- def __run_callback(key, kind, object, &blk) #:nodoc:
+ def __run_callbacks(key, kind, object, &blk) #:nodoc:
name = __callback_runner_name(key, kind)
unless object.respond_to?(name)
str = send("_#{kind}_callbacks").compile(key, object)
@@ -618,7 +606,6 @@ def define_callbacks(*callbacks)
callbacks.each do |callback|
class_attribute "_#{callback}_callbacks"
send("_#{callback}_callbacks=", CallbackChain.new(callback, config))
- __define_runner(callback)
end
end
end

0 comments on commit 40c8aa7

Please sign in to comment.
Something went wrong with that request. Please try again.