diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-01-19 08:50:35 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-02-04 20:48:29 +0900 |
commit | 09525527a5a35cb60106aadc8c8c95fa0e4bf83e (patch) | |
tree | f891799caaf3797a172af6fdf61231ca41638f40 /activesupport/lib/active_support | |
parent | f8d3fed1679b487485e32b52b15fe154efe0f10c (diff) | |
download | rails-09525527a5a35cb60106aadc8c8c95fa0e4bf83e.tar.gz rails-09525527a5a35cb60106aadc8c8c95fa0e4bf83e.tar.bz2 rails-09525527a5a35cb60106aadc8c8c95fa0e4bf83e.zip |
Deprecate passing string to `:if` and `:unless` conditional options on `set_callback` and `skip_callback`
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/callbacks.rb | 16 |
1 files changed, 16 insertions, 0 deletions
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 <tt>:raise</tt> option is set to <tt>false</tt>). 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| |