aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdan Gusiev <agresso@gmail.com>2012-09-07 14:42:31 +0300
committerBogdan Gusiev <agresso@gmail.com>2012-09-07 14:42:31 +0300
commit6777f7b75d1d10ff148e3d72cef3ef642de5bda3 (patch)
treee9c074fc4a993978e8ba31ce4b47843f41b0549c
parente20a790b9e63ff7ff71753b24bd88c0a62dc2cf7 (diff)
downloadrails-6777f7b75d1d10ff148e3d72cef3ef642de5bda3.tar.gz
rails-6777f7b75d1d10ff148e3d72cef3ef642de5bda3.tar.bz2
rails-6777f7b75d1d10ff148e3d72cef3ef642de5bda3.zip
AS::Callbacks: deprecate monkey patch of object callbacks
-rw-r--r--actionpack/lib/action_controller/caching/actions.rb2
-rw-r--r--actionpack/test/controller/filters_test.rb14
-rw-r--r--activesupport/lib/active_support/callbacks.rb1
3 files changed, 9 insertions, 8 deletions
diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb
index 0238135bc1..eb3aa05a25 100644
--- a/actionpack/lib/action_controller/caching/actions.rb
+++ b/actionpack/lib/action_controller/caching/actions.rb
@@ -132,7 +132,7 @@ module ActionController #:nodoc:
options.values_at(:cache_path, :store_options, :layout)
end
- def filter(controller)
+ def around(controller)
cache_layout = @cache_layout.respond_to?(:call) ? @cache_layout.call(controller) : @cache_layout
path_options = if @cache_path.respond_to?(:call)
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb
index afc00a3c9d..d203601771 100644
--- a/actionpack/test/controller/filters_test.rb
+++ b/actionpack/test/controller/filters_test.rb
@@ -193,7 +193,7 @@ class FilterTest < ActionController::TestCase
end
class ConditionalClassFilter
- def self.filter(controller) controller.instance_variable_set(:"@ran_class_filter", true) end
+ def self.before(controller) controller.instance_variable_set(:"@ran_class_filter", true) end
end
class OnlyConditionClassController < ConditionalFilterController
@@ -309,7 +309,7 @@ class FilterTest < ActionController::TestCase
end
class AuditFilter
- def self.filter(controller)
+ def self.before(controller)
controller.instance_variable_set(:"@was_audited", true)
end
end
@@ -449,7 +449,7 @@ class FilterTest < ActionController::TestCase
class ErrorToRescue < Exception; end
class RescuingAroundFilterWithBlock
- def filter(controller)
+ def around(controller)
begin
yield
rescue ErrorToRescue => ex
@@ -894,7 +894,7 @@ end
class ControllerWithFilterClass < PostsController
class YieldingFilter < DefaultFilter
- def self.filter(controller)
+ def self.around(controller)
yield
raise After
end
@@ -905,7 +905,7 @@ end
class ControllerWithFilterInstance < PostsController
class YieldingFilter < DefaultFilter
- def filter(controller)
+ def around(controller)
yield
raise After
end
@@ -916,13 +916,13 @@ end
class ControllerWithFilterMethod < PostsController
class YieldingFilter < DefaultFilter
- def filter(controller)
+ def around(controller)
yield
raise After
end
end
- around_filter YieldingFilter.new.method(:filter), :only => :raises_after
+ around_filter YieldingFilter.new.method(:around), :only => :raises_after
end
class ControllerWithProcFilter < PostsController
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index a55f68497c..7166c21268 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -279,6 +279,7 @@ module ActiveSupport
def _normalize_legacy_filter(kind, filter)
if !filter.respond_to?(kind) && filter.respond_to?(:filter)
+ ActiveSupport::Deprecation.warn("Filter object with #filter method is deprecated. Define method corresponding to filter type (#before, #after or #around).")
filter.singleton_class.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{kind}(context, &block) filter(context, &block) end
RUBY_EVAL