Sha256: 86ba8dde13a43a156f924231b104170db4f08ea479a75b54fac070faea8bd582
Contents?: true
Size: 506 Bytes
Versions: 19
Compression:
Stored size: 506 Bytes
Contents
require "cgi" class Phrase::Api::QueryParams def self.encode(value, key=nil) case value when Array then value.map { |v| encode(v, "#{key}[]") }.join("&") when Hash then value.map { |k,v| encode(v, append_key(key,k)) }.join("&") when nil then "" else "#{key}=#{CGI.escape(value.to_s)}" end end def self.append_key(root_key, key) if root_key.nil? key else "#{root_key}[#{key.to_s}]" end end private_class_method :append_key end
Version data entries
19 entries across 19 versions & 1 rubygems