Class: Aws::Plugins::DynamoDBSimpleAttributes
- Inherits:
-
Seahorse::Client::Plugin
- Object
- Seahorse::Client::Plugin
- Aws::Plugins::DynamoDBSimpleAttributes
- Defined in:
- lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb
Overview
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')
}
)
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' },
}
)
## 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')
}
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>,
# "age"=> <struct s=nil, n="35", b=nil, ss=nil, ns=nil, bs=nil>,
# "tags"=> <struct s=nil, n=nil, b=nil, ss=['simple', 'attributes'], ns=nil, bs=nil>,
# "data"=> <struct s=nil, n=nil, b="data", ss=nil, ns=nil, bs=nil>,
# }
Defined Under Namespace
Classes: Handler, ValueTranslator
Instance Method Summary collapse
Methods inherited from Seahorse::Client::Plugin
#add_options, #after_initialize, after_initialize, after_initialize_hooks, before_initialize, #before_initialize, before_initialize_hooks, handlers, option, options
Methods included from Seahorse::Client::HandlerBuilder
#handle, #handle_request, #handle_response, #handler_for, #new_handler
Instance Method Details
#add_handlers(handlers, config) ⇒ Object
79 80 81 82 83 |
# File 'lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb', line 79 def add_handlers(handlers, config) if config.simple_attributes handlers.add(Handler, step: :initialize) end end |