No commit activity in last 3 years
No release in over 3 years
A plugin for Roda which exposes symbolized request params
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 3.2
 Project Readme

Roda::SymbolizedParams

A Roda plugin that exposes symbolized request params.

Installation

gem 'roda-symbolized_params'

Usage

require "roda"

class App < Roda
  plugin :symbolized_params

  route do |r|
    r.root do
      params[:foo] # symbolized request params
    end
  end
end

This plugin exposes the #params method which is just a wrapper around request.params, but with symbolized keys.

This plugin is similar to the built-in indifferent_params plugin, but with real symbolized keys. Advantage of this plugin is that you don't have to always keep in mind that you still actually have string keys, so you can normally use methods like Hash#fetch, and you can use params as keyword arguments.

An obvious disadvantage is that new symbols are created each time, which have to be garbage collected. So you shouldn't use this plugin in Ruby versions < 2.2.0, because Ruby Symbol GC was only introduced in Ruby 2.2.0.

License

MIT