diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2016-08-10 09:57:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-10 09:57:07 -0700 |
commit | 79e27b909ea983a4bec6d246ad23e77c5a2e47f4 (patch) | |
tree | 23160166668ec587f049ad9cb2a4c35f331e9e89 /actionpack/lib/action_controller/metal/parameter_encoding.rb | |
parent | dfb246118afbc6b59f6517eaed00208aa6c7e4b5 (diff) | |
parent | 496d744fa31665de810b404de968ba86ed87c319 (diff) | |
download | rails-79e27b909ea983a4bec6d246ad23e77c5a2e47f4.tar.gz rails-79e27b909ea983a4bec6d246ad23e77c5a2e47f4.tar.bz2 rails-79e27b909ea983a4bec6d246ad23e77c5a2e47f4.zip |
Merge pull request #26092 from kerrizor/kerrizor/force-param-encoding
Allow specifying encoding of parameters by action
Diffstat (limited to 'actionpack/lib/action_controller/metal/parameter_encoding.rb')
-rw-r--r-- | actionpack/lib/action_controller/metal/parameter_encoding.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/metal/parameter_encoding.rb b/actionpack/lib/action_controller/metal/parameter_encoding.rb new file mode 100644 index 0000000000..f5d3dabb45 --- /dev/null +++ b/actionpack/lib/action_controller/metal/parameter_encoding.rb @@ -0,0 +1,29 @@ +module ActionController + module ParameterEncoding + extend ActiveSupport::Concern + + module ClassMethods + def inherited(klass) + super + klass.setup_param_encode + end + + def setup_param_encode + @_parameter_encodings = {} + end + + def encoding_for_param(action, param) + if @_parameter_encodings[action.to_s] && @_parameter_encodings[action.to_s][param.to_s] + @_parameter_encodings[action.to_s][param.to_s] + else + ::Encoding::UTF_8 + end + end + + def parameter_encoding(action, param_name, encoding) + @_parameter_encodings[action.to_s] ||= {} + @_parameter_encodings[action.to_s][param_name.to_s] = encoding + end + end + end +end |