From 09525527a5a35cb60106aadc8c8c95fa0e4bf83e Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Thu, 19 Jan 2017 08:50:35 +0900 Subject: Deprecate passing string to `:if` and `:unless` conditional options on `set_callback` and `skip_callback` --- activesupport/lib/active_support/callbacks.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'activesupport/lib/active_support/callbacks.rb') diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 16455c8b93..b3d3f3caec 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -667,6 +667,14 @@ module ActiveSupport # existing chain rather than appended. def set_callback(name, *filter_list, &block) type, filters, options = normalize_callback_params(filter_list, block) + + if options[:if].is_a?(String) || options[:unless].is_a?(String) + ActiveSupport::Deprecation.warn(<<-MSG.squish) + Passing string to :if and :unless conditional options is deprecated + and will be removed in Rails 5.2 without replacement. + MSG + end + self_chain = get_callbacks name mapped = filters.map do |filter| Callback.build(self_chain, filter, type, options) @@ -690,6 +698,14 @@ module ActiveSupport # already been set (unless the :raise option is set to false). def skip_callback(name, *filter_list, &block) type, filters, options = normalize_callback_params(filter_list, block) + + if options[:if].is_a?(String) || options[:unless].is_a?(String) + ActiveSupport::Deprecation.warn(<<-MSG.squish) + Passing string to :if and :unless conditional options is deprecated + and will be removed in Rails 5.2 without replacement. + MSG + end + options[:raise] = true unless options.key?(:raise) __update_callbacks(name) do |target, chain| -- cgit v1.2.3