1
+ require 'active_support/deprecation'
2
+
1
3
module AbstractController
2
4
module Callbacks
3
5
extend ActiveSupport ::Concern
@@ -42,21 +44,23 @@ def _normalize_callback_option(options, from, to) # :nodoc:
42
44
end
43
45
end
44
46
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.
47
48
#
48
49
# ==== Parameters
49
50
# * <tt>names</tt> - A list of valid names that could be used for
50
51
# callbacks. Note that skipping uses Ruby equality, so it's
51
52
# impossible to skip a callback defined using an anonymous proc
52
- # using #skip_filter
53
+ # using #skip_action_callback
53
54
def skip_action_callback ( *names )
54
55
skip_before_action ( *names )
55
56
skip_after_action ( *names )
56
57
skip_around_action ( *names )
57
58
end
58
59
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
60
64
61
65
# Take callback names and an optional callback proc, normalize them,
62
66
# then call the block with each callback. This allows us to abstract
@@ -85,95 +89,83 @@ def _insert_callbacks(callbacks, block = nil)
85
89
# :call-seq: before_action(names, block)
86
90
#
87
91
# Append a callback before actions. See _insert_callbacks for parameter details.
88
- # Aliased as before_filter.
89
92
90
93
##
91
94
# :method: prepend_before_action
92
95
#
93
96
# :call-seq: prepend_before_action(names, block)
94
97
#
95
98
# Prepend a callback before actions. See _insert_callbacks for parameter details.
96
- # Aliased as prepend_before_filter.
97
99
98
100
##
99
101
# :method: skip_before_action
100
102
#
101
103
# :call-seq: skip_before_action(names)
102
104
#
103
105
# Skip a callback before actions. See _insert_callbacks for parameter details.
104
- # Aliased as skip_before_filter.
105
106
106
107
##
107
108
# :method: append_before_action
108
109
#
109
110
# :call-seq: append_before_action(names, block)
110
111
#
111
112
# Append a callback before actions. See _insert_callbacks for parameter details.
112
- # Aliased as append_before_filter.
113
113
114
114
##
115
115
# :method: after_action
116
116
#
117
117
# :call-seq: after_action(names, block)
118
118
#
119
119
# Append a callback after actions. See _insert_callbacks for parameter details.
120
- # Aliased as after_filter.
121
120
122
121
##
123
122
# :method: prepend_after_action
124
123
#
125
124
# :call-seq: prepend_after_action(names, block)
126
125
#
127
126
# Prepend a callback after actions. See _insert_callbacks for parameter details.
128
- # Aliased as prepend_after_filter.
129
127
130
128
##
131
129
# :method: skip_after_action
132
130
#
133
131
# :call-seq: skip_after_action(names)
134
132
#
135
133
# Skip a callback after actions. See _insert_callbacks for parameter details.
136
- # Aliased as skip_after_filter.
137
134
138
135
##
139
136
# :method: append_after_action
140
137
#
141
138
# :call-seq: append_after_action(names, block)
142
139
#
143
140
# Append a callback after actions. See _insert_callbacks for parameter details.
144
- # Aliased as append_after_filter.
145
141
146
142
##
147
143
# :method: around_action
148
144
#
149
145
# :call-seq: around_action(names, block)
150
146
#
151
147
# Append a callback around actions. See _insert_callbacks for parameter details.
152
- # Aliased as around_filter.
153
148
154
149
##
155
150
# :method: prepend_around_action
156
151
#
157
152
# :call-seq: prepend_around_action(names, block)
158
153
#
159
154
# Prepend a callback around actions. See _insert_callbacks for parameter details.
160
- # Aliased as prepend_around_filter.
161
155
162
156
##
163
157
# :method: skip_around_action
164
158
#
165
159
# :call-seq: skip_around_action(names)
166
160
#
167
161
# Skip a callback around actions. See _insert_callbacks for parameter details.
168
- # Aliased as skip_around_filter.
169
162
170
163
##
171
164
# :method: append_around_action
172
165
#
173
166
# :call-seq: append_around_action(names, block)
174
167
#
175
168
# Append a callback around actions. See _insert_callbacks for parameter details.
176
- # Aliased as append_around_filter.
177
169
178
170
# set up before_action, prepend_before_action, skip_before_action, etc.
179
171
# for each of before, after, and around.
@@ -184,15 +176,21 @@ def _insert_callbacks(callbacks, block = nil)
184
176
end
185
177
end
186
178
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
188
183
189
184
define_method "prepend_#{ callback } _action" do |*names , &blk |
190
185
_insert_callbacks ( names , blk ) do |name , options |
191
186
set_callback ( :process_action , callback , name , options . merge ( :prepend => true ) )
192
187
end
193
188
end
194
189
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
196
194
197
195
# Skip a before, after or around callback. See _insert_callbacks
198
196
# for details on the allowed parameters.
@@ -202,11 +200,17 @@ def _insert_callbacks(callbacks, block = nil)
202
200
end
203
201
end
204
202
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
206
207
207
208
# *_action is the same as append_*_action
208
209
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
210
214
end
211
215
end
212
216
end
0 commit comments