Sha256: bbdb9dc0fe5bd1710159b08953855e98ad0fdd2f7ad9261d531c30360f3e4e14
Contents?: true
Size: 621 Bytes
Versions: 5
Compression:
Stored size: 621 Bytes
Contents
module Grape module Batch # Convert hash to www form url params class Converter class << self def encode(value, key = nil, out_hash = {}) case value when Hash value.each { |k, v| encode(v, append_key(key, k), out_hash) } when Array value.each { |v| encode(v, "#{key}[]", out_hash) } else out_hash[key] = value end value ? out_hash : '' end def append_key(root_key, key) root_key ? :"#{root_key}[#{key.to_s}]" : :"#{key}" end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems