module Roda::RodaPlugins::IndifferentParams::InstanceMethods

Public Instance Methods

params() click to toggle source

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

# File lib/roda/plugins/indifferent_params.rb, line 21
def params
  @_params ||= indifferent_params(request.params)
end

Private Instance Methods

indifferent_params(params) click to toggle source

Recursively process the request params and convert hashes to support indifferent access, leaving other values alone.

# File lib/roda/plugins/indifferent_params.rb, line 30
def indifferent_params(params)
  case params 
  when Hash
    h = Hash.new{|h, k| h[k.to_s] if Symbol === k}
    params.each{|k, v| h[k] = indifferent_params(v)}
    h
  when Array
    params.map{|x| indifferent_params(x)}
  else
    params
  end
end