public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Refactor Filter predicate methods to use inheritance. [#815 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
joshsusser (author)
Tue Aug 12 22:38:45 -0700 2008
lifo (committer)
Wed Aug 13 13:48:37 -0700 2008
commit  2561be005b1180883ccf1d0f7ad38858d9348064
tree    bb5e50509c7f6cf3902babfb324d312e16a82f92
parent  1ee9e3fa5c924bef4aba3d53796f48f5badbd06f
...
109
110
111
 
112
113
 
114
115
116
117
 
118
119
120
121
 
122
123
124
...
170
171
172
 
 
 
 
173
174
175
...
212
213
214
 
 
 
 
215
216
217
...
224
225
226
 
 
 
 
227
228
229
...
109
110
111
112
113
 
114
115
116
117
 
118
119
120
121
 
122
123
124
125
...
171
172
173
174
175
176
177
178
179
180
...
217
218
219
220
221
222
223
224
225
226
...
233
234
235
236
237
238
239
240
241
242
0
@@ -109,16 +109,17 @@ module ActionController #:nodoc:
0
         update_options! options
0
       end
0
 
0
+      # override these to return true in appropriate subclass
0
       def before?
0
-        self.class == BeforeFilter
0
+        false
0
       end
0
 
0
       def after?
0
-        self.class == AfterFilter
0
+        false
0
       end
0
 
0
       def around?
0
-        self.class == AroundFilter
0
+        false
0
       end
0
 
0
       # Make sets of strings from :only/:except options
0
@@ -170,6 +171,10 @@ module ActionController #:nodoc:
0
         :around
0
       end
0
 
0
+      def around?
0
+        true
0
+      end
0
+
0
       def call(controller, &block)
0
         if should_run_callback?(controller)
0
           method = filter_responds_to_before_and_after? ? around_proc : self.method
0
@@ -212,6 +217,10 @@ module ActionController #:nodoc:
0
         :before
0
       end
0
 
0
+      def before?
0
+        true
0
+      end
0
+
0
       def call(controller, &block)
0
         super
0
         if controller.send!(:performed?)
0
@@ -224,6 +233,10 @@ module ActionController #:nodoc:
0
       def type
0
         :after
0
       end
0
+
0
+      def after?
0
+        true
0
+      end
0
     end
0
 
0
     # Filters enable controllers to run shared pre- and post-processing code for its actions. These filters can be used to do

Comments