diff options
author | Prem Sichanugrist <s@sikac.hu> | 2015-12-14 09:52:52 -0500 |
---|---|---|
committer | Prem Sichanugrist <s@sikac.hu> | 2015-12-14 10:28:54 -0500 |
commit | 6d4aef984c0cd74ebd92b8d18a8e68f371fbb944 (patch) | |
tree | 2c692655134cdd6d74adf17c5a508a22592e0fc3 /actionpack/lib | |
parent | 2dd64a7bbb0cb7b65976cb0516d0f338b099a715 (diff) | |
download | rails-6d4aef984c0cd74ebd92b8d18a8e68f371fbb944.tar.gz rails-6d4aef984c0cd74ebd92b8d18a8e68f371fbb944.tar.bz2 rails-6d4aef984c0cd74ebd92b8d18a8e68f371fbb944.zip |
Make Parameters#to_h and #to_unsafe_h return HWIA
This makes these two methods to be more inline with the previous
behavior of Parameters as Parameters used to be inherited from HWIA.
Fixes #21391
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/metal/strong_parameters.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index 8af94551cf..8bc3c271e2 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -162,8 +162,8 @@ module ActionController end end - # Returns a safe +Hash+ representation of this parameter with all - # unpermitted keys removed. + # Returns a safe <tt>ActiveSupport::HashWithIndifferentAccess</tt> + # representation of this parameter with all unpermitted keys removed. # # params = ActionController::Parameters.new({ # name: 'Senjougahara Hitagi', @@ -175,15 +175,17 @@ module ActionController # safe_params.to_h # => {"name"=>"Senjougahara Hitagi"} def to_h if permitted? - @parameters.to_h + @parameters.deep_dup else slice(*self.class.always_permitted_parameters).permit!.to_h end end - # Returns an unsafe, unfiltered +Hash+ representation of this parameter. + # Returns an unsafe, unfiltered + # <tt>ActiveSupport::HashWithIndifferentAccess</tt> representation of this + # parameter. def to_unsafe_h - @parameters.to_h + @parameters.deep_dup end alias_method :to_unsafe_hash, :to_unsafe_h |