1
0
Fork 0
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:
Josh Susser 2008-08-12 22:38:45 -07:00 committed by Pratik Naik
parent 1ee9e3fa5c
commit 2561be005b

View file

@ -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