diff options
author | Benjamin Quorning <benjamin@quorning.net> | 2016-02-17 14:48:35 +0100 |
---|---|---|
committer | Benjamin Quorning <benjamin@quorning.net> | 2016-02-19 09:18:08 +0100 |
commit | 30440363c077dc081f7f14a2a40ca72b0fbaae67 (patch) | |
tree | 2cfd83cd5b328ca11b95143c3aeb9934fa1f8467 /actionpack/lib | |
parent | 08fd9f4f1174ce20f8ecbcda1c2509bb598ce200 (diff) | |
download | rails-30440363c077dc081f7f14a2a40ca72b0fbaae67.tar.gz rails-30440363c077dc081f7f14a2a40ca72b0fbaae67.tar.bz2 rails-30440363c077dc081f7f14a2a40ca72b0fbaae67.zip |
Deprecate AC::Parameters#== with a Hash
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/metal/strong_parameters.rb | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index 3d3015ad07..25ec3cf5b6 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -144,16 +144,21 @@ module ActionController end # Returns true if another +Parameters+ object contains the same content and - # permitted flag, or other Hash-like object contains the same content. - def ==(other_hash) - if other_hash.respond_to?(:permitted?) - self.permitted? == other_hash.permitted? && self.parameters == other_hash.parameters + # permitted flag. + def ==(other) + if other.respond_to?(:permitted?) + self.permitted? == other.permitted? && self.parameters == other.parameters + elsif other.is_a?(Hash) + ActiveSupport::Deprecation.warn <<-WARNING.squish + Comparing equality between `ActionController::Parameters` and a + `Hash` is deprecated and will be removed in Rails 5.1. Please only do + comparisons between instances of `ActionController::Parameters`. If + you need to compare to a hash, first convert it using + `ActionController::Parameters#new`. + WARNING + @parameters == other.with_indifferent_access else - if other_hash.is_a?(Hash) - @parameters == other_hash.with_indifferent_access - else - @parameters == other_hash - end + @parameters == other end end |