1+ require 'active_support/deprecation'
2+
13module AbstractController
24 module Callbacks
35 extend ActiveSupport ::Concern
@@ -42,21 +44,23 @@ def _normalize_callback_option(options, from, to) # :nodoc:
4244 end
4345 end
4446
45- # Skip before, after, and around action callbacks matching any of the names
46- # Aliased as skip_filter.
47+ # Skip before, after, and around action callbacks matching any of the names.
4748 #
4849 # ==== Parameters
4950 # * <tt>names</tt> - A list of valid names that could be used for
5051 # callbacks. Note that skipping uses Ruby equality, so it's
5152 # impossible to skip a callback defined using an anonymous proc
52- # using #skip_filter
53+ # using #skip_action_callback
5354 def skip_action_callback ( *names )
5455 skip_before_action ( *names )
5556 skip_after_action ( *names )
5657 skip_around_action ( *names )
5758 end
5859
59- alias_method :skip_filter , :skip_action_callback
60+ def skip_filter ( *names )
61+ ActiveSupport ::Deprecation . warn ( "#{ callback } _filter is deprecated and will removed in Rails 5. Use #{ callback } _action instead." )
62+ skip_action_callback ( *names )
63+ end
6064
6165 # Take callback names and an optional callback proc, normalize them,
6266 # then call the block with each callback. This allows us to abstract
@@ -85,95 +89,83 @@ def _insert_callbacks(callbacks, block = nil)
8589 # :call-seq: before_action(names, block)
8690 #
8791 # Append a callback before actions. See _insert_callbacks for parameter details.
88- # Aliased as before_filter.
8992
9093 ##
9194 # :method: prepend_before_action
9295 #
9396 # :call-seq: prepend_before_action(names, block)
9497 #
9598 # Prepend a callback before actions. See _insert_callbacks for parameter details.
96- # Aliased as prepend_before_filter.
9799
98100 ##
99101 # :method: skip_before_action
100102 #
101103 # :call-seq: skip_before_action(names)
102104 #
103105 # Skip a callback before actions. See _insert_callbacks for parameter details.
104- # Aliased as skip_before_filter.
105106
106107 ##
107108 # :method: append_before_action
108109 #
109110 # :call-seq: append_before_action(names, block)
110111 #
111112 # Append a callback before actions. See _insert_callbacks for parameter details.
112- # Aliased as append_before_filter.
113113
114114 ##
115115 # :method: after_action
116116 #
117117 # :call-seq: after_action(names, block)
118118 #
119119 # Append a callback after actions. See _insert_callbacks for parameter details.
120- # Aliased as after_filter.
121120
122121 ##
123122 # :method: prepend_after_action
124123 #
125124 # :call-seq: prepend_after_action(names, block)
126125 #
127126 # Prepend a callback after actions. See _insert_callbacks for parameter details.
128- # Aliased as prepend_after_filter.
129127
130128 ##
131129 # :method: skip_after_action
132130 #
133131 # :call-seq: skip_after_action(names)
134132 #
135133 # Skip a callback after actions. See _insert_callbacks for parameter details.
136- # Aliased as skip_after_filter.
137134
138135 ##
139136 # :method: append_after_action
140137 #
141138 # :call-seq: append_after_action(names, block)
142139 #
143140 # Append a callback after actions. See _insert_callbacks for parameter details.
144- # Aliased as append_after_filter.
145141
146142 ##
147143 # :method: around_action
148144 #
149145 # :call-seq: around_action(names, block)
150146 #
151147 # Append a callback around actions. See _insert_callbacks for parameter details.
152- # Aliased as around_filter.
153148
154149 ##
155150 # :method: prepend_around_action
156151 #
157152 # :call-seq: prepend_around_action(names, block)
158153 #
159154 # Prepend a callback around actions. See _insert_callbacks for parameter details.
160- # Aliased as prepend_around_filter.
161155
162156 ##
163157 # :method: skip_around_action
164158 #
165159 # :call-seq: skip_around_action(names)
166160 #
167161 # Skip a callback around actions. See _insert_callbacks for parameter details.
168- # Aliased as skip_around_filter.
169162
170163 ##
171164 # :method: append_around_action
172165 #
173166 # :call-seq: append_around_action(names, block)
174167 #
175168 # Append a callback around actions. See _insert_callbacks for parameter details.
176- # Aliased as append_around_filter.
177169
178170 # set up before_action, prepend_before_action, skip_before_action, etc.
179171 # for each of before, after, and around.
@@ -184,15 +176,21 @@ def _insert_callbacks(callbacks, block = nil)
184176 end
185177 end
186178
187- alias_method :"#{ callback } _filter" , :"#{ callback } _action"
179+ define_method "#{ callback } _filter" do |*names , &blk |
180+ ActiveSupport ::Deprecation . warn ( "#{ callback } _filter is deprecated and will removed in Rails 5. Use #{ callback } _action instead." )
181+ send ( "#{ callback } _action" , *names , &blk )
182+ end
188183
189184 define_method "prepend_#{ callback } _action" do |*names , &blk |
190185 _insert_callbacks ( names , blk ) do |name , options |
191186 set_callback ( :process_action , callback , name , options . merge ( :prepend => true ) )
192187 end
193188 end
194189
195- alias_method :"prepend_#{ callback } _filter" , :"prepend_#{ callback } _action"
190+ define_method "prepend_#{ callback } _filter" do |*names , &blk |
191+ ActiveSupport ::Deprecation . warn ( "prepend_#{ callback } _filter is deprecated and will removed in Rails 5. Use prepend_#{ callback } _action instead." )
192+ send ( "prepend_#{ callback } _action" , *names , &blk )
193+ end
196194
197195 # Skip a before, after or around callback. See _insert_callbacks
198196 # for details on the allowed parameters.
@@ -202,11 +200,17 @@ def _insert_callbacks(callbacks, block = nil)
202200 end
203201 end
204202
205- alias_method :"skip_#{ callback } _filter" , :"skip_#{ callback } _action"
203+ define_method "skip_#{ callback } _filter" do |*names , &blk |
204+ ActiveSupport ::Deprecation . warn ( "skip_#{ callback } _filter is deprecated and will removed in Rails 5. Use skip_#{ callback } _action instead." )
205+ send ( "skip_#{ callback } _action" , *names , &blk )
206+ end
206207
207208 # *_action is the same as append_*_action
208209 alias_method :"append_#{ callback } _action" , :"#{ callback } _action" # alias_method :append_before_action, :before_action
209- alias_method :"append_#{ callback } _filter" , :"#{ callback } _action" # alias_method :append_before_filter, :before_action
210+ define_method "append_#{ callback } _filter" do |*names , &blk |
211+ ActiveSupport ::Deprecation . warn ( "append_#{ callback } _filter is deprecated and will removed in Rails 5. Use append_#{ callback } _action instead." )
212+ send ( "append_#{ callback } _action" , *names , &blk )
213+ end
210214 end
211215 end
212216 end
0 commit comments