Class: Aws::DynamoDB::AttributeValue::Marshaler Private
- Inherits:
-
Object
- Object
- Aws::DynamoDB::AttributeValue::Marshaler
- 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.
Constant Summary collapse
- HASHY_TEST =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
lambda { |val| val.nil? ? false : val.respond_to?(:to_h) }
- STRINGY_TEST =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
lambda { |val| val.respond_to?(:to_str) }
Instance Method Summary collapse
- #format(obj) ⇒ Object private
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.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/aws-sdk-dynamodb/attribute_value.rb', line 29 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 HASHY_TEST hash = obj.to_h hash.each.with_object(m:{}) do |(key, value), map| map[:m][key.to_s] = format(value) end when true, false then { bool: obj } when nil then { null: true } else msg = 'unsupported type, expected Hash, Array, Set, String, Numeric, '\ "IO, true, false, or nil, got #{obj.class.name}" raise ArgumentError, msg end end |