Sha256: 342772f448ecafaf38e06421a324b4e27070003f9c99a026cc55c7a24b089f43
Contents?: true
Size: 624 Bytes
Versions: 5
Compression:
Stored size: 624 Bytes
Contents
module Grape module Batch class HashConverter def self.encode(value, key = nil, out_hash = {}) case value when Hash then value.each { |k,v| encode(v, append_key(key,k), out_hash) } out_hash when Array then value.each { |v| encode(v, "#{key}[]", out_hash) } out_hash when nil then '' else out_hash[key] = value out_hash end end private def self.append_key(root_key, key) root_key.nil? ? :"#{key}" : :"#{root_key}[#{key.to_s}]" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems