module Tito::Base::ParamNester

cf. github.com/sumofparts/lifter/commit/e224946538ea0be337b7418c2946dbf1c2018b6b

Public Class Methods

append_key(root_key, key) click to toggle source
# File lib/tito/base.rb, line 184
def self.append_key(root_key, key)
  root_key.nil? ? :"#{key}" : :"#{root_key}[#{key.to_s}]"
end
encode(value, key = nil, out_hash = {}) click to toggle source
# File lib/tito/base.rb, line 168
def self.encode(value, key = nil, out_hash = {})
  case value
  when Hash
    value.each { |k,v| encode(v, append_key(key, k), out_hash) }
    out_hash
  when Array
    value.each { |v| encode(v, "#{key}[]", out_hash) }
    out_hash
  when nil
    ''
  else
    out_hash[key] = value
    out_hash
  end
end