Skip to content

Commit 489a8f2

Browse files
committed
Partially revert deprecation of *_filter
We are going to deprecate only on Rails 5 to make easier plugin maintainers support different Rails versions. Right now we are only discouraging their usage. This reverts commit 6c5f43b. Conflicts: actionpack/CHANGELOG.md
1 parent 1c6bb0e commit 489a8f2

File tree

3 files changed

+9
-36
lines changed

3 files changed

+9
-36
lines changed

actionpack/CHANGELOG.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
application. Use of a symbol should be replaced with `action: symbol`.
33
Use of a string without a "#" should be replaced with `controller: string`.
44

5-
* Deprecate all *_filter callbacks in favor of *_action callbacks.
6-
7-
*Rafael Mendonça França*
8-
95
* Fix URL generation with `:trailing_slash` such that it does not add
106
a trailing slash after `.:format`
117

actionpack/lib/abstract_controller/callbacks.rb

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require 'active_support/deprecation'
2-
31
module AbstractController
42
module Callbacks
53
extend ActiveSupport::Concern
@@ -56,11 +54,7 @@ def skip_action_callback(*names)
5654
skip_after_action(*names)
5755
skip_around_action(*names)
5856
end
59-
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
57+
alias_method :skip_filter, :skip_action_callback
6458

6559
# Take callback names and an optional callback proc, normalize them,
6660
# then call the block with each callback. This allows us to abstract
@@ -175,22 +169,14 @@ def _insert_callbacks(callbacks, block = nil)
175169
set_callback(:process_action, callback, name, options)
176170
end
177171
end
178-
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
172+
alias_method :"#{callback}_filter", :"#{callback}_action"
183173

184174
define_method "prepend_#{callback}_action" do |*names, &blk|
185175
_insert_callbacks(names, blk) do |name, options|
186176
set_callback(:process_action, callback, name, options.merge(:prepend => true))
187177
end
188178
end
189-
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
179+
alias_method :"prepend_#{callback}_filter", :"prepend_#{callback}_action"
194180

195181
# Skip a before, after or around callback. See _insert_callbacks
196182
# for details on the allowed parameters.
@@ -199,18 +185,11 @@ def _insert_callbacks(callbacks, block = nil)
199185
skip_callback(:process_action, callback, name, options)
200186
end
201187
end
202-
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
188+
alias_method :"skip_#{callback}_filter", :"skip_#{callback}_action"
207189

208190
# *_action is the same as append_*_action
209-
alias_method :"append_#{callback}_action", :"#{callback}_action" # alias_method :append_before_action, :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
191+
alias_method :"append_#{callback}_action", :"#{callback}_action"
192+
alias_method :"append_#{callback}_filter", :"#{callback}_action"
214193
end
215194
end
216195
end

actionpack/test/abstract/callbacks_test.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,9 @@ class TestCallbacksWithArgs < ActiveSupport::TestCase
267267
end
268268

269269
class AliasedCallbacks < ControllerWithCallbacks
270-
ActiveSupport::Deprecation.silence do
271-
before_filter :first
272-
after_filter :second
273-
around_filter :aroundz
274-
end
270+
before_filter :first
271+
after_filter :second
272+
around_filter :aroundz
275273

276274
def first
277275
@text = "Hello world"

0 commit comments

Comments
 (0)