0
# Filter:: <Array[Symbol, (Symbol, String, Proc)]>
0
class Merb::AbstractController
0
include Merb::RenderMixin
0
- include Merb::GeneralControllerMixin
0
class_inheritable_accessor :_before_filters, :_after_filters, :_template_root
0
self._before_filters, self._after_filters = [], []
0
@@ -101,21 +100,22 @@ class Merb::AbstractController
0
- attr_accessor :_benchmarks, :_thrown_content
0
+ attr_accessor :_benchmarks, :_thrown_content
, :_body0
# *args<Object>:: The args are ignored
0
- @thrown_content = AbstractController._default_thrown_content
0
# action<~to_s>:: The action to dispatch to. This will be #send'ed in _call_action
0
def _dispatch(action=:to_s)
0
caught = catch(:halt) do
0
- result = _call_filters(_before_filters
)
0
+ result = _call_filters(_before_filters
.reverse)
0
@_benchmarks[:before_filters_time] = Time.now - start if _before_filters
0
@@ -131,7 +131,7 @@ class Merb::AbstractController
0
_call_filters(_after_filters)
0
- @_benchmarks[:after_filters_time] = Time.now - start if
after_filters
0
+ @_benchmarks[:after_filters_time] = Time.now - start if
_after_filters
0
# This method exists to provide an overridable hook for ActionArgs
0
@@ -155,14 +155,12 @@ class Merb::AbstractController
0
# * execute the +Proc+, in the context of the controller (self will
0
def _call_filters(filter_set)
0
- action = params[:action].intern
0
(filter_set || []).each do |filter, rule|
0
# * no :only or the current action is in the :only list
0
# * no :exclude or the current action is not in the :exclude list
0
- if (!rule.key?(:only) || rule[:only].include?(action)) &&
0
- (!rule.key?(:exclude) || !rule[:exclude].include?(action))
0
+ if (!rule.key?(:only) || rule[:only].include?(@action)) &&
0
+ (!rule.key?(:exclude) || !rule[:exclude].include?(@action))
0
when Symbol, String then send(filter)
0
when Proc then self.instance_eval(&filter)
0
@@ -182,7 +180,7 @@ class Merb::AbstractController
0
# If the filter already exists, its options will be replaced
0
- def self.after(filter
, opts = {})
0
+ def self.after(filter
= nil, opts = {}, &block)
0
add_filter(self._after_filters, filter, opts)
0
@@ -195,8 +193,8 @@ class Merb::AbstractController
0
# If the filter already exists, its options will be replaced with opts
0
- def self.before(filter, opts = {})
0
- add_filter(self._before_filters, filter, opts)
0
+ def self.before(filter = nil, opts = {}, &block)
0
+ add_filter(self._before_filters, filter || block, opts)
0
# Skip an after filter that has been previously defined (perhaps in a superclass)
0
@@ -212,7 +210,7 @@ class Merb::AbstractController
0
# filter<Symbol>:: A filter name to skip
0
def self.skip_before(filter)
0
- skip_filter(self._before_filters
, filter)
0
+ skip_filter(self._before_filters
, filter)
Comments
No one has commented yet.