Module: ActionDispatch::Http::Parameters::ClassMethods
- Defined in:
- lib/action_dispatch/http/parameters.rb
Instance Method Summary collapse
-
#parameter_parsers=(parsers) ⇒ Object
Configure the parameter parser for a given mime type.
Instance Method Details
#parameter_parsers=(parsers) ⇒ Object
Configure the parameter parser for a given mime type.
It accepts a hash where the key is the symbol of the mime type and the value is a proc.
original_parsers = ActionDispatch::Request.parameter_parsers
xml_parser = -> (raw_post) { Hash.from_xml(raw_post) || {} }
new_parsers = original_parsers.merge(xml: xml_parser)
ActionDispatch::Request.parameter_parsers = new_parsers
42 43 44 |
# File 'lib/action_dispatch/http/parameters.rb', line 42 def parameter_parsers=(parsers) @parameter_parsers = parsers.transform_keys { |key| key.respond_to?(:symbol) ? key.symbol : key } end |