diff options
-rw-r--r-- | actionpack/lib/abstract_controller/callbacks.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/callbacks.rb | 6 | ||||
-rw-r--r-- | activesupport/lib/active_support/new_callbacks.rb | 30 |
3 files changed, 19 insertions, 19 deletions
diff --git a/actionpack/lib/abstract_controller/callbacks.rb b/actionpack/lib/abstract_controller/callbacks.rb index 379eaf6d8e..7f12561da5 100644 --- a/actionpack/lib/abstract_controller/callbacks.rb +++ b/actionpack/lib/abstract_controller/callbacks.rb @@ -16,7 +16,7 @@ module AbstractController # Override AbstractController::Base's process_action to run the # process_action callbacks around the normal behavior. def process_action(method_name) - _run_process_action_callbacks(method_name) do + run_callbacks(:process_action, method_name) do super end end diff --git a/actionpack/lib/action_dispatch/middleware/callbacks.rb b/actionpack/lib/action_dispatch/middleware/callbacks.rb index 56d6da1706..e1764b064c 100644 --- a/actionpack/lib/action_dispatch/middleware/callbacks.rb +++ b/actionpack/lib/action_dispatch/middleware/callbacks.rb @@ -37,12 +37,12 @@ module ActionDispatch def initialize(app, prepare_each_request = false) @app, @prepare_each_request = app, prepare_each_request - _run_prepare_callbacks + run_callbacks(:prepare) end def call(env) - _run_call_callbacks do - _run_prepare_callbacks if @prepare_each_request + run_callbacks(:call) do + run_callbacks(:prepare) if @prepare_each_request @app.call(env) end end diff --git a/activesupport/lib/active_support/new_callbacks.rb b/activesupport/lib/active_support/new_callbacks.rb index 2f0853d84a..cee811efcf 100644 --- a/activesupport/lib/active_support/new_callbacks.rb +++ b/activesupport/lib/active_support/new_callbacks.rb @@ -26,7 +26,7 @@ module ActiveSupport # end # # def save - # _run_set_callback :save,s do + # run_callbacks :save do # puts "- save" # end # end @@ -65,7 +65,7 @@ module ActiveSupport # end # # def save - # _run_set_callback :save,s do + # run_callbacks :save do # puts "- save" # end # end @@ -85,8 +85,8 @@ module ActiveSupport klass.extend ClassMethods end - def run_callbacks(kind, options = {}, &blk) - send("_run_#{kind}_callbacks", &blk) + def run_callbacks(kind, *args, &block) + send("_run_#{kind}_callbacks", *args, &block) end class Callback @@ -165,7 +165,7 @@ module ActiveSupport end RUBY_EVAL end - + # This will supply contents for before and around filters, and no # contents for after filters (for the forward pass). def start(key=nil, object=nil) @@ -220,7 +220,7 @@ module ActiveSupport end end end - + # This will supply contents for around and after filters, but not # before filters (for the backward pass). def end(key=nil, object=nil) @@ -276,7 +276,7 @@ module ActiveSupport # Symbols:: Already methods # Strings:: class_eval'ed into methods # Procs:: define_method'ed into methods - # Objects:: + # Objects:: # a method is created that calls the before_foo method # on the object. # @@ -378,15 +378,15 @@ module ActiveSupport end module ClassMethods - # Make the _run_set_callback :save method. The generated method takes + # Make the run_callbacks :save method. The generated method takes # a block that it'll yield to. It'll call the before and around filters # in order, yield the block, and then run the after filters. - # - # _run_set_callback :save do + # + # run_callbacks :save do # save # end # - # The _run_set_callback :save method can optionally take a key, which + # The run_callbacks :save method can optionally take a key, which # will be used to compile an optimized callback method for each # key. See #define_callbacks for more information. # @@ -407,6 +407,7 @@ module ActiveSupport #{body} end end + private :_run_#{symbol}_callbacks RUBY_EVAL silence_warnings do @@ -414,7 +415,7 @@ module ActiveSupport class_eval body, __FILE__, line end end - + # This is called the first time a callback is called with a particular # key. It creates a new callback method for the key, calculating # which callbacks can be omitted because of per_key conditions. @@ -449,8 +450,7 @@ module ActiveSupport # set_callback :save, :after, :after_meth, :if => :condition # set_callback :save, :around, lambda { |r| stuff; yield; stuff } # - # It also updates the _run_<name>_callbacks method, which is the public - # API to run the callbacks. Use skip_callback to skip any defined one. + # Use skip_callback to skip any defined one. # # When creating or skipping callbacks, you can specify conditions that # are always the same for a given key. For instance, in ActionPack, @@ -463,7 +463,7 @@ module ActiveSupport # Per-Key conditions are evaluated only once per use of a given key. # In the case of the above example, you would do: # - # _run_dispatch_callbacks(action_name) { ... dispatch stuff ... } + # run_callbacks(:dispatch, action_name) { ... dispatch stuff ... } # # In that case, each action_name would get its own compiled callback # method that took into consideration the per_key conditions. This |