Sha256: f5b81b81a50814f788cdee400940590d2a5d05b05717d4fae2f85d71d7d8a07b

Contents?: true

Size: 633 Bytes

Versions: 2

Compression:

Stored size: 633 Bytes

Contents

# LeadTune API Ruby Gem
#
# http://github.com/leadtune/leadtune-ruby
# Eric Wollesen (mailto:devs@leadtune.com)
# Copyright 2010 LeadTune LLC

class Hash
  # File merb/core_ext/hash.rb, line 87
  def to_params
    params = ''
    stack = []

    each do |k, v|
      if v.is_a?(Hash)
        stack << [k,v]
      else
        params << "#{k}=#{v}&"
      end
    end

    stack.each do |parent, hash|
      hash.each do |k, v|
        if v.is_a?(Hash)
          stack << ["#{parent}[#{k}]", v]
        else
          params << "#{parent}[#{k}]=#{v}&"
        end
      end
    end

    params.chop! # trailing &
    params
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
leadtune-0.0.2 lib/hash_extensions.rb
leadtune-0.0.1 lib/hash_extensions.rb