diff options
author | Josh Susser <josh@hasmanythrough.com> | 2008-08-12 22:38:45 -0700 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-08-13 21:48:37 +0100 |
commit | 2561be005b1180883ccf1d0f7ad38858d9348064 (patch) | |
tree | bb5e50509c7f6cf3902babfb324d312e16a82f92 | |
parent | 1ee9e3fa5c924bef4aba3d53796f48f5badbd06f (diff) | |
download | rails-2561be005b1180883ccf1d0f7ad38858d9348064.tar.gz rails-2561be005b1180883ccf1d0f7ad38858d9348064.tar.bz2 rails-2561be005b1180883ccf1d0f7ad38858d9348064.zip |
Refactor Filter predicate methods to use inheritance. [#815 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
-rw-r--r-- | actionpack/lib/action_controller/filters.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/filters.rb b/actionpack/lib/action_controller/filters.rb index 10dc0cc45b..1d7236f18a 100644 --- a/actionpack/lib/action_controller/filters.rb +++ b/actionpack/lib/action_controller/filters.rb @@ -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 |