class Aws::Plugins::DynamoDBSimpleAttributes
Simplifies working with Amazon DynamoDB attribute values. Translates attribute values for requests and responses to sensible Ruby natives.
This plugin is enabled by default for all {DynamoDB::Client} objects. You can disable this plugin by passing `simple_attributes: false` to the client constructor:
ddb = Aws::DynamoDB::Client.new(simple_attributes: false)
## Input Examples
With this plugin *enabled*, `simple_attributes: true`:
dynamodb.put_item( table_name: 'aws-sdk', item: { id: 'uuid', age: 35, tags: Set.new(%w(simple attributes)), data: StringIO.new('data'), scores: [5, 4.5, 4.9, nil], name: { first: 'John', last: 'Doe', } } )
With this plugin *disabled*, `simple_attributes: false`:
# note that all types are prefixed in a hash and that # numeric types must be serialized as strings dynamodb.put_item( table_name: 'aws-sdk', item: { 'id' => { s: 'uuid' }, 'age' => { n: '35' }, 'tags' => { ss: ['simple', 'attributes'] }, 'data' => { b: 'data' }, 'scores' => { l: [ { n: '5' }, { n: '4.5' }, { n: '4.9' }, { null: true }, ] }, 'name' => { m: { 'first' => { s: 'John' }, 'last' => { s: 'Doe' }, } } } )
## Output Examples
With this plugin *enabled*, `simple_attributes: true`:
resp = dynamodb.get(table_name: 'aws-sdk', key: { id: 'uuid' }) resp.item { id: 'uuid', age: 35, tags: Set.new(%w(simple attributes)), data: StringIO.new('data'), scores: [5, 4.5, 4.9, nil], name: { first: 'John', last: 'Doe', } }
With this plugin *disabled*, `simple_attributes: false`:
# note that the request `:key` had to be type prefixed resp = dynamodb.get(table_name: 'aws-sdk', key: { 'id' => { s: 'uuid' }}) resp.item # { # "id"=> <struct s='uuid', n=nil, b=nil, ss=nil, ns=nil, bs=nil, m=nil, l=nil, null=nil, bool=nil> # "age"=> <struct s=nil, n="35", b=nil, ss=nil, ns=nil, bs=nil, m=nil, l=nil, null=nil, bool=nil> # ... # }
@seahorse.client.option [Boolean] :simple_attributes (true)
Enables working with DynamoDB attribute values using hashes, arrays, sets, integers, floats, booleans, and nil. Disabling this option requires that all attribute values have their types specified, e.g. `{ s: 'abc' }` instead of simply `'abc'`.
Public Instance Methods
add_handlers(handlers, config)
click to toggle source
# File lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb, line 102 def add_handlers(handlers, config) if config.simple_attributes handlers.add(Handler, step: :initialize) end end