aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2016-08-02 15:53:45 +0200
committerKasper Timm Hansen <kaspth@gmail.com>2016-08-02 15:53:45 +0200
commit0e0cff0f27eb76e84fd2226396f16bb52fe754bd (patch)
treef792eb58328cd6458a3d78ff5967e22e631960ba /actionpack/lib
parent6eb978234cdce57e75c36a096fa76a634705c7c8 (diff)
downloadrails-0e0cff0f27eb76e84fd2226396f16bb52fe754bd.tar.gz
rails-0e0cff0f27eb76e84fd2226396f16bb52fe754bd.tar.bz2
rails-0e0cff0f27eb76e84fd2226396f16bb52fe754bd.zip
Replace implicit formats with a case statement.
The coder that Psych passes in has a `tag` method we can use to detect which serialization format we're reviving for. Use it and make it clearer alongside the `load_tags` fiddling.
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index d2db982a6e..13e46789e9 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -601,19 +601,20 @@ module ActionController
end
def init_with(coder) # :nodoc:
- if coder.map['elements']
- # YAML 2.0.9's Hash subclass format from Rails 4.2, where keys and values
+ case coder.tag
+ when '!ruby/hash:ActionController::Parameters'
+ # YAML 2.0.8's format where hash instance variables weren't stored.
+ @parameters = coder.map.with_indifferent_access
+ @permitted = false
+ when '!ruby/hash-with-ivars:ActionController::Parameters'
+ # YAML 2.0.9's Hash subclass format where keys and values
# were stored under an elements hash and `permitted` within an ivars hash.
@parameters = coder.map['elements'].with_indifferent_access
@permitted = coder.map['ivars'][:@permitted]
- elsif coder.map['parameters']
+ when '!ruby/object:ActionController::Parameters'
# YAML's Object format. Only needed because of the format
# backwardscompability above, otherwise equivalent to YAML's initialization.
@parameters, @permitted = coder.map['parameters'], coder.map['permitted']
- else
- # YAML 2.0.8's format where hash instance variables weren't stored.
- @parameters = coder.map.with_indifferent_access
- @permitted = false
end
end