Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #7560 from bogdan/deprecate_callbacks_monkeypatch

AS::Callbacks: deprecate monkey patch of object callbacks
  • Loading branch information...
commit c5ac6da5c213d61acc8a3552cf58a224be92ba53 2 parents e20a790 + 6777f7b
@josevalim josevalim authored
View
2  actionpack/lib/action_controller/caching/actions.rb
@@ -132,7 +132,7 @@ def initialize(options, &block)
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)
View
14 actionpack/test/controller/filters_test.rb
@@ -193,7 +193,7 @@ class ExceptConditionProcController < ConditionalFilterController
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 ImplicitProcController < PrependingController
end
class AuditFilter
- def self.filter(controller)
+ def self.before(controller)
controller.instance_variable_set(:"@was_audited", true)
end
end
@@ -449,7 +449,7 @@ def show
class ErrorToRescue < Exception; end
class RescuingAroundFilterWithBlock
- def filter(controller)
+ def around(controller)
begin
yield
rescue ErrorToRescue => ex
@@ -894,7 +894,7 @@ def without_exception
class ControllerWithFilterClass < PostsController
class YieldingFilter < DefaultFilter
- def self.filter(controller)
+ def self.around(controller)
yield
raise After
end
@@ -905,7 +905,7 @@ def self.filter(controller)
class ControllerWithFilterInstance < PostsController
class YieldingFilter < DefaultFilter
- def filter(controller)
+ def around(controller)
yield
raise After
end
@@ -916,13 +916,13 @@ def filter(controller)
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
View
1  activesupport/lib/active_support/callbacks.rb
@@ -279,6 +279,7 @@ def #{method_name}(&blk)
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
Please sign in to comment.
Something went wrong with that request. Please try again.