Sha256: 15b081eb63141eb5ecd23cc79f049c414d2eafc5dd5b6352bf2b6b8710053224
Contents?: true
Size: 625 Bytes
Versions: 2
Compression:
Stored size: 625 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
grape-batch-2.1.0 | lib/grape/batch/hash_converter.rb |
grape-batch-2.0.1 | lib/grape/batch/hash_converter.rb |