Skip to content

Commit

Permalink
Partially revert deprecation of *_filter
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rafaelfranca committed Jun 3, 2014
1 parent 1c6bb0e commit 489a8f2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 36 deletions.
4 changes: 0 additions & 4 deletions actionpack/CHANGELOG.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
application. Use of a symbol should be replaced with `action: symbol`. application. Use of a symbol should be replaced with `action: symbol`.
Use of a string without a "#" should be replaced with `controller: string`. Use of a string without a "#" should be replaced with `controller: string`.


* Deprecate all *_filter callbacks in favor of *_action callbacks.

*Rafael Mendonça França*

* Fix URL generation with `:trailing_slash` such that it does not add * Fix URL generation with `:trailing_slash` such that it does not add
a trailing slash after `.:format` a trailing slash after `.:format`


Expand Down
33 changes: 6 additions & 27 deletions actionpack/lib/abstract_controller/callbacks.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'active_support/deprecation'

module AbstractController module AbstractController
module Callbacks module Callbacks
extend ActiveSupport::Concern extend ActiveSupport::Concern
Expand Down Expand Up @@ -56,11 +54,7 @@ def skip_action_callback(*names)
skip_after_action(*names) skip_after_action(*names)
skip_around_action(*names) skip_around_action(*names)
end end

alias_method :skip_filter, :skip_action_callback
def skip_filter(*names)
ActiveSupport::Deprecation.warn("#{callback}_filter is deprecated and will removed in Rails 5. Use #{callback}_action instead.")
skip_action_callback(*names)
end


# Take callback names and an optional callback proc, normalize them, # Take callback names and an optional callback proc, normalize them,
# then call the block with each callback. This allows us to abstract # then call the block with each callback. This allows us to abstract
Expand Down Expand Up @@ -175,22 +169,14 @@ def _insert_callbacks(callbacks, block = nil)
set_callback(:process_action, callback, name, options) set_callback(:process_action, callback, name, options)
end end
end end

alias_method :"#{callback}_filter", :"#{callback}_action"
define_method "#{callback}_filter" do |*names, &blk|
ActiveSupport::Deprecation.warn("#{callback}_filter is deprecated and will removed in Rails 5. Use #{callback}_action instead.")
send("#{callback}_action", *names, &blk)
end


define_method "prepend_#{callback}_action" do |*names, &blk| define_method "prepend_#{callback}_action" do |*names, &blk|
_insert_callbacks(names, blk) do |name, options| _insert_callbacks(names, blk) do |name, options|
set_callback(:process_action, callback, name, options.merge(:prepend => true)) set_callback(:process_action, callback, name, options.merge(:prepend => true))
end end
end end

alias_method :"prepend_#{callback}_filter", :"prepend_#{callback}_action"
define_method "prepend_#{callback}_filter" do |*names, &blk|
ActiveSupport::Deprecation.warn("prepend_#{callback}_filter is deprecated and will removed in Rails 5. Use prepend_#{callback}_action instead.")
send("prepend_#{callback}_action", *names, &blk)
end


# Skip a before, after or around callback. See _insert_callbacks # Skip a before, after or around callback. See _insert_callbacks
# for details on the allowed parameters. # for details on the allowed parameters.
Expand All @@ -199,18 +185,11 @@ def _insert_callbacks(callbacks, block = nil)
skip_callback(:process_action, callback, name, options) skip_callback(:process_action, callback, name, options)
end end
end end

alias_method :"skip_#{callback}_filter", :"skip_#{callback}_action"
define_method "skip_#{callback}_filter" do |*names, &blk|
ActiveSupport::Deprecation.warn("skip_#{callback}_filter is deprecated and will removed in Rails 5. Use skip_#{callback}_action instead.")
send("skip_#{callback}_action", *names, &blk)
end


# *_action is the same as append_*_action # *_action is the same as append_*_action
alias_method :"append_#{callback}_action", :"#{callback}_action" # alias_method :append_before_action, :before_action alias_method :"append_#{callback}_action", :"#{callback}_action"
define_method "append_#{callback}_filter" do |*names, &blk| alias_method :"append_#{callback}_filter", :"#{callback}_action"
ActiveSupport::Deprecation.warn("append_#{callback}_filter is deprecated and will removed in Rails 5. Use append_#{callback}_action instead.")
send("append_#{callback}_action", *names, &blk)
end
end end
end end
end end
Expand Down
8 changes: 3 additions & 5 deletions actionpack/test/abstract/callbacks_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -267,11 +267,9 @@ class TestCallbacksWithArgs < ActiveSupport::TestCase
end end


class AliasedCallbacks < ControllerWithCallbacks class AliasedCallbacks < ControllerWithCallbacks
ActiveSupport::Deprecation.silence do before_filter :first
before_filter :first after_filter :second
after_filter :second around_filter :aroundz
around_filter :aroundz
end


def first def first
@text = "Hello world" @text = "Hello world"
Expand Down

0 comments on commit 489a8f2

Please sign in to comment.