Sha256: fd75064002b5698537ec5a72dbd7cd1ee58a03264bb707ba26a158652f2478c0

Contents?: true

Size: 653 Bytes

Versions: 20

Compression:

Stored size: 653 Bytes

Contents

# -*- encoding: utf-8 -*-

module Nimbu
  module Request
    # Deals with normalazing client supplied parameter keys.
    module Normalizer

      # Turns any keys from nested hashes including nested arrays into strings
      #
      def normalize!(params)
        case params
        when Hash
          params.keys.each do |k|
            params[k.to_s] = params.delete(k)
            normalize!(params[k.to_s])
          end
        when Array
          params.map! do |el|
            normalize!(el)
          end
        else
          params.to_s
        end
        return params
      end

      end # Normalizer
    end # Request
  end # Nimbu

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
nimbu-api-0.5.0 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.4.4 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.4.3 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.4.2 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.4.1 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.4.0 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.3.0 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.2.1 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.2 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.2.beta.3 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.2.beta.2 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.2.beta.1 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.2.beta lib/nimbu-api/request/normalizer.rb
nimbu-api-0.1.5 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.1.4 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.1.3 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.1.1 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.1 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.0.2 lib/nimbu-api/request/normalizer.rb
nimbu-api-0.0.1 lib/nimbu-api/request/normalizer.rb