Class: TinyDyno::Adapter::AttributeValue

Inherits:
Object
  • Object
show all
Defined in:
lib/tiny_dyno/adapter/attributes.rb

Defined Under Namespace

Classes: Marshaler, Unmarshaler

Instance Method Summary collapse

Constructor Details

#initializeAttributeValue

utilize the same type coercions as in the ruby aws-sdk ( github.com/aws/aws-sdk-ruby/blob/master/aws-sdk-core/lib/aws-sdk-core/dynamodb/attribute_value.rb ) however in a more deterministic fashion the type conversion employed by the simple attribute feature is purely based on the value field tiny_dyno enforces coercion into the designated target data type or raises an error on mismatch



17
18
19
20
# File 'lib/tiny_dyno/adapter/attributes.rb', line 17

def initialize
  @marshaler = Marshaler.new
  @unmarshaler = Unmarshaler.new
end

Instance Method Details

#marshal(type:, value:) ⇒ Object



22
23
24
# File 'lib/tiny_dyno/adapter/attributes.rb', line 22

def marshal(type:, value:)
  @marshaler.format(type: type, obj: value)
end

#unmarshal(value) ⇒ Object



26
27
28
# File 'lib/tiny_dyno/adapter/attributes.rb', line 26

def unmarshal(value)
  @unmarshaler.format(value)
end