class Aws::DynamoDB::AttributeValue::Marshaler

def format(obj)

def format(obj)
  case obj
  when Hash
    obj.each.with_object(m:{}) do |(key, value), map|
      map[:m][key.to_s] = format(value)
    end
  when Array
    obj.each.with_object(l:[]) do |value, list|
      list[:l] << format(value)
    end
  when String then { s: obj }
  when Symbol then { s: obj.to_s }
  when STRINGY_TEST then { s: obj.to_str }
  when Numeric then { n: obj.to_s }
  when StringIO, IO then { b: obj }
  when Set then format_set(obj)
  when true, false then { bool: obj }
  when nil then { null: true }
  else
    msg = "unsupported type, expected Hash, Array, Set, String, Numeric, "
    msg << "IO, true, false, or nil, got #{obj.class.name}"
    raise ArgumentError, msg
  end
end

def format_set(set)

def format_set(set)
  return { es: [] } if set.empty?
  case set.first
  when String, Symbol then { ss: set.map(&:to_s) }
  when STRINGY_TEST then { ss: set.map(&:to_str) }
  when Numeric then { ns: set.map(&:to_s) }
  when StringIO, IO then { bs: set.to_a }
  else
    msg = "set types only support String, Numeric, or IO objects"
    raise ArgumentError, msg
  end
end