class Aws::Plugins::DynamoDBSimpleAttributes::ValueTranslator
@api private
def apply(values)
def apply(values) structure(@shape, values) if @shape end
def initialize(shape, mode)
-
mode
(Symbol<:marshal,:unmarshal>
) -- -
shape
(Seahorse::Model::Shapes::Shape
) --
def initialize(shape, mode) @shape = shape @mode = mode end
def list(shape, values)
def list(shape, values) return values unless values.is_a?(Array) values.inject([]) do |list, value| list << translate(shape.member, value) end end
def map(shape, values)
def map(shape, values) return values unless values.is_a?(Hash) values.each.with_object({}) do |(key, value), hash| hash[key] = translate(shape.value, value) end end
def structure(shape, values)
def structure(shape, values) if values.is_a?(Struct) values.members.each do |key| values[key] = translate(shape.member(key), values[key]) end values elsif values.is_a?(Hash) values.each.with_object({}) do |(key, value), hash| hash[key] = translate(shape.member(key), value) end else values end end
def translate(shape, value)
def translate(shape, value) if shape.name == 'AttributeValue' DynamoDB::AttributeValue.new.send(@mode, value) else translate_complex(shape, value) end end
def translate_complex(shape, value)
def translate_complex(shape, value) case shape when Seahorse::Model::Shapes::Structure then structure(shape, value) when Seahorse::Model::Shapes::List then list(shape, value) when Seahorse::Model::Shapes::Map then map(shape, value) else value end end