mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Refactor Filter predicate methods to use inheritance. [#815 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
parent
1ee9e3fa5c
commit
2561be005b
1 changed files with 16 additions and 3 deletions
|
@ -109,16 +109,17 @@ module ActionController #:nodoc:
|
|||
update_options! options
|
||||
end
|
||||
|
||||
# override these to return true in appropriate subclass
|
||||
def before?
|
||||
self.class == BeforeFilter
|
||||
false
|
||||
end
|
||||
|
||||
def after?
|
||||
self.class == AfterFilter
|
||||
false
|
||||
end
|
||||
|
||||
def around?
|
||||
self.class == AroundFilter
|
||||
false
|
||||
end
|
||||
|
||||
# Make sets of strings from :only/:except options
|
||||
|
@ -170,6 +171,10 @@ module ActionController #:nodoc:
|
|||
:around
|
||||
end
|
||||
|
||||
def around?
|
||||
true
|
||||
end
|
||||
|
||||
def call(controller, &block)
|
||||
if should_run_callback?(controller)
|
||||
method = filter_responds_to_before_and_after? ? around_proc : self.method
|
||||
|
@ -212,6 +217,10 @@ module ActionController #:nodoc:
|
|||
:before
|
||||
end
|
||||
|
||||
def before?
|
||||
true
|
||||
end
|
||||
|
||||
def call(controller, &block)
|
||||
super
|
||||
if controller.send!(:performed?)
|
||||
|
@ -224,6 +233,10 @@ module ActionController #:nodoc:
|
|||
def type
|
||||
:after
|
||||
end
|
||||
|
||||
def after?
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
# Filters enable controllers to run shared pre- and post-processing code for its actions. These filters can be used to do
|
||||
|
|
Loading…
Reference in a new issue