Class: Aws::DynamoDB::AttributeValue::Unmarshaler Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-dynamodb/attribute_value.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#format(obj) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/aws-sdk-dynamodb/attribute_value.rb', line 78

def format(obj)
  type, value = extract_type_and_value(obj)
  case type
  when :m
    value.each.with_object({}) do |(k, v), map|
      map[k] = format(v)
    end
  when :l then value.map { |v| format(v) }
  when :s then value
  when :n then BigDecimal(value)
  when :b then StringIO.new(value)
  when :null then nil
  when :bool then value
  when :ss then Set.new(value)
  when :ns then Set.new(value.map { |n| BigDecimal(n) })
  when :bs then Set.new(value.map { |b| StringIO.new(b) })
  else
    raise ArgumentError, "unhandled type #{type.inspect}"
  end
end