From 489a8f2a44dc9cea09154ee1ee2557d1f037c7d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 3 Jun 2014 19:53:28 -0300 Subject: [PATCH] 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 6c5f43bab8206747a8591435b2aa0ff7051ad3de. Conflicts: actionpack/CHANGELOG.md --- actionpack/CHANGELOG.md | 4 --- .../lib/abstract_controller/callbacks.rb | 33 ++++--------------- actionpack/test/abstract/callbacks_test.rb | 8 ++--- 3 files changed, 9 insertions(+), 36 deletions(-) diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index fb633f11d5..3b20aec20d 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -2,10 +2,6 @@ application. Use of a symbol should be replaced with `action: symbol`. 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 a trailing slash after `.:format` diff --git a/actionpack/lib/abstract_controller/callbacks.rb b/actionpack/lib/abstract_controller/callbacks.rb index 252e297c69..ca5c80cd71 100644 --- a/actionpack/lib/abstract_controller/callbacks.rb +++ b/actionpack/lib/abstract_controller/callbacks.rb @@ -1,5 +1,3 @@ -require 'active_support/deprecation' - module AbstractController module Callbacks extend ActiveSupport::Concern @@ -56,11 +54,7 @@ module AbstractController skip_after_action(*names) skip_around_action(*names) end - - 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 + alias_method :skip_filter, :skip_action_callback # Take callback names and an optional callback proc, normalize them, # then call the block with each callback. This allows us to abstract @@ -175,22 +169,14 @@ module AbstractController set_callback(:process_action, callback, name, options) end end - - 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 + alias_method :"#{callback}_filter", :"#{callback}_action" define_method "prepend_#{callback}_action" do |*names, &blk| _insert_callbacks(names, blk) do |name, options| set_callback(:process_action, callback, name, options.merge(:prepend => true)) end end - - 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 + alias_method :"prepend_#{callback}_filter", :"prepend_#{callback}_action" # Skip a before, after or around callback. See _insert_callbacks # for details on the allowed parameters. @@ -199,18 +185,11 @@ module AbstractController skip_callback(:process_action, callback, name, options) end end - - 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 + alias_method :"skip_#{callback}_filter", :"skip_#{callback}_action" # *_action is the same as append_*_action - alias_method :"append_#{callback}_action", :"#{callback}_action" # alias_method :append_before_action, :before_action - define_method "append_#{callback}_filter" do |*names, &blk| - 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 + alias_method :"append_#{callback}_action", :"#{callback}_action" + alias_method :"append_#{callback}_filter", :"#{callback}_action" end end end diff --git a/actionpack/test/abstract/callbacks_test.rb b/actionpack/test/abstract/callbacks_test.rb index 07571602e4..8cba049485 100644 --- a/actionpack/test/abstract/callbacks_test.rb +++ b/actionpack/test/abstract/callbacks_test.rb @@ -267,11 +267,9 @@ module AbstractController end class AliasedCallbacks < ControllerWithCallbacks - ActiveSupport::Deprecation.silence do - before_filter :first - after_filter :second - around_filter :aroundz - end + before_filter :first + after_filter :second + around_filter :aroundz def first @text = "Hello world"