diff options
author | Bogdan Gusiev <agresso@gmail.com> | 2011-12-30 10:53:46 +0200 |
---|---|---|
committer | Bogdan Gusiev <agresso@gmail.com> | 2011-12-30 10:53:46 +0200 |
commit | 2a78886a1d4c57cd4a07a380cf3ccc213ea97116 (patch) | |
tree | c11fde5480ad442440b9bc950e14eb3f930dd85d /activesupport/lib/active_support/callbacks.rb | |
parent | e43b2b35c7042c87fd18e3ecd55c14eabd5746ba (diff) | |
download | rails-2a78886a1d4c57cd4a07a380cf3ccc213ea97116.tar.gz rails-2a78886a1d4c57cd4a07a380cf3ccc213ea97116.tar.bz2 rails-2a78886a1d4c57cd4a07a380cf3ccc213ea97116.zip |
AS::Callbacks: remove __define_runner
Diffstat (limited to 'activesupport/lib/active_support/callbacks.rb')
-rw-r--r-- | activesupport/lib/active_support/callbacks.rb | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 0495741c15..df3aeb6b8a 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -77,8 +77,8 @@ module ActiveSupport # 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 @@ module ActiveSupport 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 @@ module ActiveSupport callbacks.each do |callback| class_attribute "_#{callback}_callbacks" send("_#{callback}_callbacks=", CallbackChain.new(callback, config)) - __define_runner(callback) end end end |