module Angus::Params

Public Class Methods

indifferent_hash() click to toggle source

Creates a Hash with indifferent access.

# File lib/angus/utils/params.rb, line 19
def self.indifferent_hash
  Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
end
indifferent_params(object) click to toggle source

Enable string or symbol key access to the nested params hash.

# File lib/angus/utils/params.rb, line 5
def self.indifferent_params(object)
  case object
    when Hash
      new_hash = indifferent_hash
      object.each { |key, value| new_hash[key] = indifferent_params(value) }
      new_hash
    when Array
      object.map { |item| indifferent_params(item) }
    else
      object
  end
end