Ruby / Roda - Web Framework / Plugins / :indifferent_params


Introduction

The :indifferent_params plugin adds a #.params instance method which returns a copy of the request params hash that will automatically convert symbols to strings.

Example

plugin :indifferent_params

route do |r|
  
  params[:foo]
  
end

The params hash is initialised lazily, so you only pay the penalty of copying the request params if you call the #.params method.

Note that there is a rack-indifferent gem that automatically makes Rack use indifferent params.

Using rack-indifferent gem is faster and has some other minor advantages over the :indifferent_params plugin, though it affects Rack itself instead of just the Roda app that you load the plugin into.

InstanceMethods

#.params

A copy of the request params that will automatically convert symbols to strings.