diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-08-02 16:20:08 +0200 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2016-08-02 16:20:08 +0200 |
commit | b71732c84a4bb5f8f7cbf65c5193db97c7e31eca (patch) | |
tree | a12715a79d389264d896e009f6068f6c23a6693e /actionpack/lib/action_controller | |
parent | 0e0cff0f27eb76e84fd2226396f16bb52fe754bd (diff) | |
download | rails-b71732c84a4bb5f8f7cbf65c5193db97c7e31eca.tar.gz rails-b71732c84a4bb5f8f7cbf65c5193db97c7e31eca.tar.bz2 rails-b71732c84a4bb5f8f7cbf65c5193db97c7e31eca.zip |
Move the YAML hook closer to `init_with`.
Looked odd, so completely detached from the other necessary part of
the implementation.
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/metal/strong_parameters.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index 13e46789e9..f101c7b836 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -9,14 +9,6 @@ require 'stringio' require 'set' require 'yaml' -# Wire up YAML format compatibility with Rails 4.2. Makes the YAML parser call -# `init_with` when it encounters `!ruby/hash-with-ivars:ActionController::Parameters`, -# instead of trying to parse it as a regular hash subclass. -# Second `load_tags` is for compatibility with Psych prior to 2.0.9 where hashes -# were dumped without instance variables. -YAML.load_tags['!ruby/hash-with-ivars:ActionController::Parameters'] = 'ActionController::Parameters' -YAML.load_tags['!ruby/hash:ActionController::Parameters'] = 'ActionController::Parameters' - module ActionController # Raised when a required parameter is missing. # @@ -600,6 +592,15 @@ module ActionController "<#{self.class} #{@parameters} permitted: #{@permitted}>" end + def self.hook_into_yaml_loading # :nodoc: + # Wire up YAML format compatibility with Rails 4.2 and Psych 2.0.8 and 2.0.9+. + # Makes the YAML parser call `init_with` when it encounters the keys below + # instead of trying its own parsing routines. + YAML.load_tags['!ruby/hash-with-ivars:ActionController::Parameters'] = name + YAML.load_tags['!ruby/hash:ActionController::Parameters'] = name + end + hook_into_yaml_loading + def init_with(coder) # :nodoc: case coder.tag when '!ruby/hash:ActionController::Parameters' |