Skip to content
A Roda plugin which symbolizes request params
Ruby
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
lib/roda/plugins
spec
.gitignore
.travis.yml
Gemfile
LICENSE.txt
README.md
Rakefile
roda-symbolized_params.gemspec

README.md

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

You can’t perform that action at this time.