aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/abstract/callbacks.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/abstract/callbacks.rb')
-rw-r--r--actionpack/lib/action_controller/abstract/callbacks.rb27
1 files changed, 21 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/abstract/callbacks.rb b/actionpack/lib/action_controller/abstract/callbacks.rb
index e4f9dd3112..affe053bac 100644
--- a/actionpack/lib/action_controller/abstract/callbacks.rb
+++ b/actionpack/lib/action_controller/abstract/callbacks.rb
@@ -1,8 +1,8 @@
module AbstractController
module Callbacks
- extend ActiveSupport::DependencyModule
+ extend ActiveSupport::Concern
- depends_on ActiveSupport::NewCallbacks
+ include ActiveSupport::NewCallbacks
included do
define_callbacks :process_action, "response_body"
@@ -13,7 +13,7 @@ module AbstractController
super
end
end
-
+
module ClassMethods
def _normalize_callback_options(options)
if only = options[:only]
@@ -21,11 +21,17 @@ module AbstractController
options[:per_key] = {:if => only}
end
if except = options[:except]
- except = Array(except).map {|e| "action_name == '#{e}'"}.join(" || ")
+ except = Array(except).map {|e| "action_name == '#{e}'"}.join(" || ")
options[:per_key] = {:unless => except}
end
end
-
+
+ def skip_filter(*names, &blk)
+ skip_before_filter(*names, &blk)
+ skip_after_filter(*names, &blk)
+ skip_around_filter(*names, &blk)
+ end
+
[:before, :after, :around].each do |filter|
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{filter}_filter(*names, &blk)
@@ -37,6 +43,15 @@ module AbstractController
end
end
+ def prepend_#{filter}_filter(*names, &blk)
+ options = names.last.is_a?(Hash) ? names.pop : {}
+ _normalize_callback_options(options)
+ names.push(blk) if block_given?
+ names.each do |name|
+ process_action_callback(:#{filter}, name, options.merge(:prepend => true))
+ end
+ end
+
def skip_#{filter}_filter(*names, &blk)
options = names.last.is_a?(Hash) ? names.pop : {}
_normalize_callback_options(options)
@@ -51,4 +66,4 @@ module AbstractController
end
end
end
-end \ No newline at end of file
+end