aws-record 2.10.0 → 2.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +335 -0
- data/LICENSE +202 -0
- data/VERSION +1 -0
- data/lib/aws-record/record/attribute.rb +9 -21
- data/lib/aws-record/record/attributes.rb +68 -78
- data/lib/aws-record/record/batch.rb +13 -12
- data/lib/aws-record/record/batch_read.rb +5 -2
- data/lib/aws-record/record/batch_write.rb +1 -12
- data/lib/aws-record/record/buildable_search.rb +33 -28
- data/lib/aws-record/record/client_configuration.rb +10 -21
- data/lib/aws-record/record/dirty_tracking.rb +30 -44
- data/lib/aws-record/record/errors.rb +1 -13
- data/lib/aws-record/record/item_collection.rb +5 -16
- data/lib/aws-record/record/item_data.rb +4 -18
- data/lib/aws-record/record/item_operations.rb +86 -93
- data/lib/aws-record/record/key_attributes.rb +1 -14
- data/lib/aws-record/record/marshalers/boolean_marshaler.rb +2 -16
- data/lib/aws-record/record/marshalers/date_marshaler.rb +1 -15
- data/lib/aws-record/record/marshalers/date_time_marshaler.rb +2 -14
- data/lib/aws-record/record/marshalers/epoch_time_marshaler.rb +1 -14
- data/lib/aws-record/record/marshalers/float_marshaler.rb +3 -19
- data/lib/aws-record/record/marshalers/integer_marshaler.rb +3 -19
- data/lib/aws-record/record/marshalers/list_marshaler.rb +2 -16
- data/lib/aws-record/record/marshalers/map_marshaler.rb +2 -16
- data/lib/aws-record/record/marshalers/numeric_set_marshaler.rb +3 -16
- data/lib/aws-record/record/marshalers/string_marshaler.rb +2 -16
- data/lib/aws-record/record/marshalers/string_set_marshaler.rb +3 -16
- data/lib/aws-record/record/marshalers/time_marshaler.rb +1 -14
- data/lib/aws-record/record/model_attributes.rb +14 -35
- data/lib/aws-record/record/query.rb +7 -21
- data/lib/aws-record/record/secondary_indexes.rb +23 -42
- data/lib/aws-record/record/table_config.rb +52 -74
- data/lib/aws-record/record/table_migration.rb +43 -66
- data/lib/aws-record/record/transactions.rb +67 -38
- data/lib/aws-record/record/version.rb +2 -13
- data/lib/aws-record/record.rb +30 -49
- metadata +14 -5
@@ -3,7 +3,6 @@
|
|
3
3
|
module Aws
|
4
4
|
module Record
|
5
5
|
module ItemOperations
|
6
|
-
|
7
6
|
# @api private
|
8
7
|
def self.included(sub_class)
|
9
8
|
sub_class.extend(ItemOperationsClassMethods)
|
@@ -12,12 +11,12 @@ module Aws
|
|
12
11
|
# Saves this instance of an item to Amazon DynamoDB. If this item is "new"
|
13
12
|
# as defined by having new or altered key attributes, will attempt a
|
14
13
|
# conditional
|
15
|
-
# {http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#put_item-instance_method
|
16
|
-
# call, which will not overwrite an existing
|
17
|
-
# altered non-key attributes, will perform an
|
18
|
-
# {http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#update_item-instance_method
|
19
|
-
# call. Uses this item instance's attributes
|
20
|
-
# request on your behalf.
|
14
|
+
# {http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#put_item-instance_method
|
15
|
+
# Aws::DynamoDB::Client#put_item} call, which will not overwrite an existing
|
16
|
+
# item. If the item only has altered non-key attributes, will perform an
|
17
|
+
# {http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#update_item-instance_method
|
18
|
+
# Aws::DynamoDB::Client#update_item} call. Uses this item instance's attributes
|
19
|
+
# in order to build the request on your behalf.
|
21
20
|
#
|
22
21
|
# You can use the +:force+ option to perform a simple put/overwrite
|
23
22
|
# without conditional validation or update logic.
|
@@ -38,19 +37,19 @@ module Aws
|
|
38
37
|
if ret
|
39
38
|
ret
|
40
39
|
else
|
41
|
-
raise Errors::ValidationError
|
40
|
+
raise Errors::ValidationError, 'Validation hook returned false!'
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
44
|
# Saves this instance of an item to Amazon DynamoDB. If this item is "new"
|
46
45
|
# as defined by having new or altered key attributes, will attempt a
|
47
46
|
# conditional
|
48
|
-
# {http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#put_item-instance_method
|
49
|
-
# call, which will not overwrite an
|
50
|
-
# altered non-key attributes, will perform an
|
51
|
-
# {http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#update_item-instance_method
|
52
|
-
# call. Uses this item instance's attributes
|
53
|
-
# request on your behalf.
|
47
|
+
# {http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#put_item-instance_method
|
48
|
+
# Aws::DynamoDB::Client#put_item} call, which will not overwrite an
|
49
|
+
# existing item. If the item only has altered non-key attributes, will perform an
|
50
|
+
# {http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#update_item-instance_method
|
51
|
+
# Aws::DynamoDB::Client#update_item} call. Uses this item instance's attributes
|
52
|
+
# in order to build the request on your behalf.
|
54
53
|
#
|
55
54
|
# You can use the +:force+ option to perform a simple put/overwrite
|
56
55
|
# without conditional validation or update logic.
|
@@ -70,7 +69,6 @@ module Aws
|
|
70
69
|
end
|
71
70
|
end
|
72
71
|
|
73
|
-
|
74
72
|
# Assigns the attributes provided onto the model.
|
75
73
|
#
|
76
74
|
# @example Usage Example
|
@@ -99,7 +97,7 @@ module Aws
|
|
99
97
|
opts.each do |field, new_value|
|
100
98
|
field = field.to_sym
|
101
99
|
setter = "#{field}="
|
102
|
-
raise ArgumentError
|
100
|
+
raise ArgumentError, "Invalid field: #{field} for model" unless respond_to?(setter)
|
103
101
|
public_send(setter, new_value)
|
104
102
|
end
|
105
103
|
end
|
@@ -174,42 +172,42 @@ module Aws
|
|
174
172
|
|
175
173
|
# Deletes the item instance that matches the key values of this item
|
176
174
|
# instance in Amazon DynamoDB. Uses the
|
177
|
-
# {http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#delete_item-instance_method
|
178
|
-
# API.
|
175
|
+
# {http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#delete_item-instance_method
|
176
|
+
# Aws::DynamoDB::Client#delete_item} API.
|
179
177
|
def delete!
|
180
178
|
dynamodb_client.delete_item(
|
181
179
|
table_name: self.class.table_name,
|
182
180
|
key: key_values
|
183
181
|
)
|
184
|
-
|
182
|
+
instance_variable_get('@data').destroyed = true
|
185
183
|
end
|
186
184
|
|
187
185
|
# Validates and generates the key values necessary for API operations such as the
|
188
|
-
# {http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#delete_item-instance_method
|
189
|
-
# operation.
|
186
|
+
# {http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#delete_item-instance_method
|
187
|
+
# Aws::DynamoDB::Client#delete_item} operation.
|
190
188
|
def key_values
|
191
189
|
validate_key_values
|
192
190
|
attributes = self.class.attributes
|
193
191
|
self.class.keys.values.each_with_object({}) do |attr_name, hash|
|
194
192
|
db_name = attributes.storage_name_for(attr_name)
|
195
|
-
hash[db_name] = attributes
|
196
|
-
|
197
|
-
.serialize(@data.raw_value(attr_name))
|
193
|
+
hash[db_name] = attributes.attribute_for(attr_name)
|
194
|
+
.serialize(@data.raw_value(attr_name))
|
198
195
|
end
|
199
196
|
end
|
200
197
|
|
201
198
|
# Validates key values and returns a hash consisting of the parameters
|
202
199
|
# to save the record using the
|
203
|
-
# {https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#batch_write_item-instance_method
|
204
|
-
# operation.
|
200
|
+
# {https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#batch_write_item-instance_method
|
201
|
+
# Aws::DynamoDB::Client#batch_write_item} operation.
|
205
202
|
def save_values
|
206
203
|
_build_item_for_save
|
207
204
|
end
|
208
205
|
|
209
206
|
private
|
210
|
-
|
211
|
-
|
212
|
-
|
207
|
+
|
208
|
+
def _invalid_record?(_opts)
|
209
|
+
if respond_to?(:valid?)
|
210
|
+
if !valid?
|
213
211
|
true
|
214
212
|
else
|
215
213
|
false
|
@@ -234,12 +232,11 @@ module Aws
|
|
234
232
|
}.merge(prevent_overwrite_expression)
|
235
233
|
begin
|
236
234
|
dynamodb_client.put_item(put_opts)
|
237
|
-
rescue Aws::DynamoDB::Errors::ConditionalCheckFailedException
|
238
|
-
raise Errors::ConditionalWriteFailed
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
)
|
235
|
+
rescue Aws::DynamoDB::Errors::ConditionalCheckFailedException
|
236
|
+
raise Errors::ConditionalWriteFailed,
|
237
|
+
'Conditional #put_item call failed! Check that conditional write'\
|
238
|
+
' conditions are met, or include the :force option to clobber'\
|
239
|
+
' the remote item.'
|
243
240
|
end
|
244
241
|
else
|
245
242
|
update_pairs = _dirty_changes_for_update
|
@@ -253,7 +250,7 @@ module Aws
|
|
253
250
|
table_name: self.class.table_name,
|
254
251
|
key: key_values,
|
255
252
|
update_expression: uex,
|
256
|
-
expression_attribute_names: exp_attr_names
|
253
|
+
expression_attribute_names: exp_attr_names
|
257
254
|
}
|
258
255
|
request_opts[:expression_attribute_values] = exp_attr_values unless exp_attr_values.empty?
|
259
256
|
dynamodb_client.update_item(request_opts)
|
@@ -264,7 +261,7 @@ module Aws
|
|
264
261
|
)
|
265
262
|
end
|
266
263
|
end
|
267
|
-
data =
|
264
|
+
data = instance_variable_get('@data')
|
268
265
|
data.destroyed = false
|
269
266
|
data.new_record = false
|
270
267
|
true
|
@@ -278,15 +275,11 @@ module Aws
|
|
278
275
|
|
279
276
|
def validate_key_values
|
280
277
|
missing = missing_key_values
|
281
|
-
unless missing.empty?
|
282
|
-
raise Errors::KeyMissing.new(
|
283
|
-
"Missing required keys: #{missing.join(', ')}"
|
284
|
-
)
|
285
|
-
end
|
278
|
+
raise Errors::KeyMissing, "Missing required keys: #{missing.join(', ')}" unless missing.empty?
|
286
279
|
end
|
287
280
|
|
288
281
|
def missing_key_values
|
289
|
-
self.class.keys.
|
282
|
+
self.class.keys.each_with_object([]) do |key, acc|
|
290
283
|
acc << key.last if @data.raw_value(key.last).nil?
|
291
284
|
acc
|
292
285
|
end
|
@@ -302,24 +295,23 @@ module Aws
|
|
302
295
|
def prevent_overwrite_expression
|
303
296
|
conditions = []
|
304
297
|
expression_attribute_names = {}
|
305
|
-
keys = self.class.instance_variable_get(
|
298
|
+
keys = self.class.instance_variable_get('@keys')
|
306
299
|
# Hash Key
|
307
|
-
conditions <<
|
308
|
-
expression_attribute_names[
|
300
|
+
conditions << 'attribute_not_exists(#H)'
|
301
|
+
expression_attribute_names['#H'] = keys.hash_key_attribute.database_name
|
309
302
|
# Range Key
|
310
303
|
if self.class.range_key
|
311
|
-
conditions <<
|
312
|
-
expression_attribute_names[
|
304
|
+
conditions << 'attribute_not_exists(#R)'
|
305
|
+
expression_attribute_names['#R'] = keys.range_key_attribute.database_name
|
313
306
|
end
|
314
307
|
{
|
315
|
-
condition_expression: conditions.join(
|
308
|
+
condition_expression: conditions.join(' and '),
|
316
309
|
expression_attribute_names: expression_attribute_names
|
317
310
|
}
|
318
311
|
end
|
319
312
|
|
320
313
|
def _dirty_changes_for_update
|
321
|
-
|
322
|
-
ret = dirty.inject({}) do |acc, attr_name|
|
314
|
+
ret = dirty.each_with_object({}) do |attr_name, acc|
|
323
315
|
acc[attr_name] = @data.raw_value(attr_name)
|
324
316
|
acc
|
325
317
|
end
|
@@ -327,7 +319,6 @@ module Aws
|
|
327
319
|
end
|
328
320
|
|
329
321
|
module ItemOperationsClassMethods
|
330
|
-
|
331
322
|
# @example Usage Example
|
332
323
|
# check_exp = Model.transact_check_expression(
|
333
324
|
# key: { uuid: "foo" },
|
@@ -343,11 +334,14 @@ module Aws
|
|
343
334
|
# Allows you to build a "check" expression for use in transactional
|
344
335
|
# write operations.
|
345
336
|
#
|
337
|
+
# See {Transactions.transact_write transact_write} for more info.
|
338
|
+
#
|
346
339
|
# @param [Hash] opts Options matching the :condition_check contents in
|
347
340
|
# the
|
348
|
-
# {https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#transact_write_items-instance_method
|
349
|
-
# API, with the exception that
|
350
|
-
#
|
341
|
+
# {https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#transact_write_items-instance_method
|
342
|
+
# Aws::DynamoDB::Client#transact_write_items} API, with the exception that
|
343
|
+
# keys will be marshalled for you, and the table name will be provided
|
344
|
+
# for you by the operation.
|
351
345
|
# @return [Hash] Options suitable to be used as a check expression when
|
352
346
|
# calling the +#transact_write+ operation.
|
353
347
|
def transact_check_expression(opts)
|
@@ -357,32 +351,35 @@ module Aws
|
|
357
351
|
check_key = {}
|
358
352
|
@keys.keys.each_value do |attr_sym|
|
359
353
|
unless key[attr_sym]
|
360
|
-
raise Errors::KeyMissing
|
361
|
-
"Missing required key #{attr_sym} in #{key}"
|
362
|
-
)
|
354
|
+
raise Errors::KeyMissing, "Missing required key #{attr_sym} in #{key}"
|
363
355
|
end
|
364
356
|
attr_name = attributes.storage_name_for(attr_sym)
|
365
|
-
check_key[attr_name] = attributes.attribute_for(attr_sym)
|
366
|
-
|
357
|
+
check_key[attr_name] = attributes.attribute_for(attr_sym)
|
358
|
+
.serialize(key[attr_sym])
|
367
359
|
end
|
368
360
|
opts[:key] = check_key
|
369
361
|
opts[:table_name] = table_name
|
370
362
|
opts
|
371
363
|
end
|
372
364
|
|
365
|
+
# Used in {Transactions.transact_find}, which is a way to run
|
366
|
+
# transactional find across multiple DynamoDB items, including transactions
|
367
|
+
# which get items across multiple actual or virtual tables.
|
368
|
+
#
|
369
|
+
# This operation provide extra metadata used to marshal your items after retrieval.
|
370
|
+
#
|
371
|
+
# See {Transactions.transact_find transact_find} for more info and usage example.
|
373
372
|
def tfind_opts(opts)
|
374
373
|
opts = opts.dup
|
375
374
|
key = opts.delete(:key)
|
376
375
|
request_key = {}
|
377
376
|
@keys.keys.each_value do |attr_sym|
|
378
377
|
unless key[attr_sym]
|
379
|
-
raise Errors::KeyMissing
|
380
|
-
"Missing required key #{attr_sym} in #{key}"
|
381
|
-
)
|
378
|
+
raise Errors::KeyMissing, "Missing required key #{attr_sym} in #{key}"
|
382
379
|
end
|
383
380
|
attr_name = attributes.storage_name_for(attr_sym)
|
384
|
-
request_key[attr_name] = attributes.attribute_for(attr_sym)
|
385
|
-
|
381
|
+
request_key[attr_name] = attributes.attribute_for(attr_sym)
|
382
|
+
.serialize(key[attr_sym])
|
386
383
|
end
|
387
384
|
# this is a :get item used by #transact_get_items, with the exception
|
388
385
|
# of :model_class which needs to be removed before passing along
|
@@ -413,10 +410,11 @@ module Aws
|
|
413
410
|
# or virtual tables.
|
414
411
|
#
|
415
412
|
# @param [Hash] opts Options to pass through to
|
416
|
-
# {https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#transact_get_items-instance_method
|
417
|
-
# with the exception of the
|
418
|
-
# +#tfind_opts+ operation on
|
419
|
-
# metadata used to marshal your
|
413
|
+
# {https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#transact_get_items-instance_method
|
414
|
+
# Aws::DynamoDB::Client#transact_get_items}, with the exception of the
|
415
|
+
# :transact_items array, which uses the +#tfind_opts+ operation on
|
416
|
+
# your model class to provide extra metadata used to marshal your
|
417
|
+
# items after retrieval.
|
420
418
|
# @option opts [Array] :transact_items A set of options describing
|
421
419
|
# instances of the model class to return.
|
422
420
|
# @return [OpenStruct] Structured like the client API response from
|
@@ -483,13 +481,11 @@ module Aws
|
|
483
481
|
request_key = {}
|
484
482
|
@keys.keys.each_value do |attr_sym|
|
485
483
|
unless key[attr_sym]
|
486
|
-
raise Errors::KeyMissing
|
487
|
-
"Missing required key #{attr_sym} in #{key}"
|
488
|
-
)
|
484
|
+
raise Errors::KeyMissing, "Missing required key #{attr_sym} in #{key}"
|
489
485
|
end
|
490
486
|
attr_name = attributes.storage_name_for(attr_sym)
|
491
|
-
request_key[attr_name] = attributes.attribute_for(attr_sym)
|
492
|
-
|
487
|
+
request_key[attr_name] = attributes.attribute_for(attr_sym)
|
488
|
+
.serialize(key[attr_sym])
|
493
489
|
end
|
494
490
|
request_opts = {
|
495
491
|
table_name: table_name,
|
@@ -503,7 +499,6 @@ module Aws
|
|
503
499
|
end
|
504
500
|
end
|
505
501
|
|
506
|
-
|
507
502
|
# @example Usage Example
|
508
503
|
# class MyModel
|
509
504
|
# include Aws::Record
|
@@ -552,9 +547,9 @@ module Aws
|
|
552
547
|
# MyModel.update(id: 1, name: "First", body: "Hello!")
|
553
548
|
#
|
554
549
|
# Performs an
|
555
|
-
# {http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#update_item-instance_method
|
556
|
-
# call immediately on the table,
|
557
|
-
# provided.
|
550
|
+
# {http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#update_item-instance_method
|
551
|
+
# Aws::DynamoDB::Client#update_item} call immediately on the table,
|
552
|
+
# using the attribute key/value pairs provided.
|
558
553
|
#
|
559
554
|
# @param [Hash] opts attribute-value pairs for the update operation you
|
560
555
|
# wish to perform. You must include all key attributes for a valid
|
@@ -564,12 +559,10 @@ module Aws
|
|
564
559
|
# not include all table keys.
|
565
560
|
def update(opts)
|
566
561
|
key = {}
|
567
|
-
updates = {}
|
568
562
|
@keys.keys.each_value do |attr_sym|
|
569
|
-
unless value = opts.delete(attr_sym)
|
570
|
-
raise Errors::KeyMissing
|
571
|
-
|
572
|
-
)
|
563
|
+
unless (value = opts.delete(attr_sym))
|
564
|
+
raise Errors::KeyMissing, "Missing required key #{attr_sym} in #{opts}"
|
565
|
+
|
573
566
|
end
|
574
567
|
attr_name = attributes.storage_name_for(attr_sym)
|
575
568
|
key[attr_name] = attributes.attribute_for(attr_sym).serialize(value)
|
@@ -589,16 +582,17 @@ module Aws
|
|
589
582
|
end
|
590
583
|
|
591
584
|
private
|
585
|
+
|
592
586
|
def _build_update_expression(attr_value_pairs)
|
593
587
|
set_expressions = []
|
594
588
|
remove_expressions = []
|
595
589
|
exp_attr_names = {}
|
596
590
|
exp_attr_values = {}
|
597
|
-
name_sub_token =
|
598
|
-
value_sub_token =
|
591
|
+
name_sub_token = 'UE_A'
|
592
|
+
value_sub_token = 'ue_a'
|
599
593
|
attr_value_pairs.each do |attr_sym, value|
|
600
|
-
name_sub =
|
601
|
-
value_sub =
|
594
|
+
name_sub = '#' + name_sub_token
|
595
|
+
value_sub = ':' + value_sub_token
|
602
596
|
name_sub_token = name_sub_token.succ
|
603
597
|
value_sub_token = value_sub_token.succ
|
604
598
|
|
@@ -606,7 +600,7 @@ module Aws
|
|
606
600
|
attr_name = attributes.storage_name_for(attr_sym)
|
607
601
|
exp_attr_names[name_sub] = attr_name
|
608
602
|
if _update_type_remove?(attribute, value)
|
609
|
-
remove_expressions <<
|
603
|
+
remove_expressions << name_sub.to_s
|
610
604
|
else
|
611
605
|
set_expressions << "#{name_sub} = #{value_sub}"
|
612
606
|
exp_attr_values[value_sub] = attribute.serialize(value)
|
@@ -614,21 +608,21 @@ module Aws
|
|
614
608
|
end
|
615
609
|
update_expressions = []
|
616
610
|
unless set_expressions.empty?
|
617
|
-
update_expressions <<
|
611
|
+
update_expressions << 'SET ' + set_expressions.join(', ')
|
618
612
|
end
|
619
613
|
unless remove_expressions.empty?
|
620
|
-
update_expressions <<
|
614
|
+
update_expressions << 'REMOVE ' + remove_expressions.join(', ')
|
621
615
|
end
|
622
616
|
if update_expressions.empty?
|
623
617
|
nil
|
624
618
|
else
|
625
|
-
[update_expressions.join(
|
619
|
+
[update_expressions.join(' '), exp_attr_names, exp_attr_values]
|
626
620
|
end
|
627
621
|
end
|
628
622
|
|
629
623
|
def build_item_from_resp(resp)
|
630
624
|
record = new
|
631
|
-
data = record.instance_variable_get(
|
625
|
+
data = record.instance_variable_get('@data')
|
632
626
|
attributes.attributes.each do |name, attr|
|
633
627
|
data.set_attribute(name, attr.extract(resp.item))
|
634
628
|
data.new_record = false
|
@@ -640,7 +634,6 @@ module Aws
|
|
640
634
|
value.nil? && !attribute.persist_nil?
|
641
635
|
end
|
642
636
|
end
|
643
|
-
|
644
637
|
end
|
645
638
|
end
|
646
639
|
end
|
@@ -1,19 +1,7 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You may not
|
4
|
-
# use this file except in compliance with the License. A copy of the License is
|
5
|
-
# located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is distributed on
|
10
|
-
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
11
|
-
# or implied. See the License for the specific language governing permissions
|
12
|
-
# and limitations under the License.
|
1
|
+
# frozen_string_literal: true
|
13
2
|
|
14
3
|
module Aws
|
15
4
|
module Record
|
16
|
-
|
17
5
|
# @api private
|
18
6
|
class KeyAttributes
|
19
7
|
attr_reader :keys
|
@@ -49,6 +37,5 @@ module Aws
|
|
49
37
|
@range_key = value
|
50
38
|
end
|
51
39
|
end
|
52
|
-
|
53
40
|
end
|
54
41
|
end
|
@@ -1,23 +1,10 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You may not
|
4
|
-
# use this file except in compliance with the License. A copy of the License is
|
5
|
-
# located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is distributed on
|
10
|
-
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
11
|
-
# or implied. See the License for the specific language governing permissions
|
12
|
-
# and limitations under the License.
|
1
|
+
# frozen_string_literal: true
|
13
2
|
|
14
3
|
module Aws
|
15
4
|
module Record
|
16
5
|
module Marshalers
|
17
|
-
|
18
6
|
class BooleanMarshaler
|
19
|
-
def initialize(opts = {})
|
20
|
-
end
|
7
|
+
def initialize(opts = {}); end
|
21
8
|
|
22
9
|
def type_cast(raw_value)
|
23
10
|
case raw_value
|
@@ -47,7 +34,6 @@ module Aws
|
|
47
34
|
end
|
48
35
|
end
|
49
36
|
end
|
50
|
-
|
51
37
|
end
|
52
38
|
end
|
53
39
|
end
|
@@ -1,22 +1,10 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You may not
|
4
|
-
# use this file except in compliance with the License. A copy of the License is
|
5
|
-
# located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is distributed on
|
10
|
-
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
11
|
-
# or implied. See the License for the specific language governing permissions
|
12
|
-
# and limitations under the License.
|
1
|
+
# frozen_string_literal: true
|
13
2
|
|
14
3
|
require 'date'
|
15
4
|
|
16
5
|
module Aws
|
17
6
|
module Record
|
18
7
|
module Marshalers
|
19
|
-
|
20
8
|
class DateMarshaler
|
21
9
|
def initialize(opts = {})
|
22
10
|
@formatter = opts[:formatter] || Iso8601Formatter
|
@@ -47,7 +35,6 @@ module Aws
|
|
47
35
|
raise ArgumentError, "expected a Date value or nil, got #{date.class}"
|
48
36
|
end
|
49
37
|
end
|
50
|
-
|
51
38
|
end
|
52
39
|
|
53
40
|
module Iso8601Formatter
|
@@ -55,7 +42,6 @@ module Aws
|
|
55
42
|
date.iso8601
|
56
43
|
end
|
57
44
|
end
|
58
|
-
|
59
45
|
end
|
60
46
|
end
|
61
47
|
end
|
@@ -1,22 +1,10 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You may not
|
4
|
-
# use this file except in compliance with the License. A copy of the License is
|
5
|
-
# located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is distributed on
|
10
|
-
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
11
|
-
# or implied. See the License for the specific language governing permissions
|
12
|
-
# and limitations under the License.
|
1
|
+
# frozen_string_literal: true
|
13
2
|
|
14
3
|
require 'date'
|
15
4
|
|
16
5
|
module Aws
|
17
6
|
module Record
|
18
7
|
module Marshalers
|
19
|
-
|
20
8
|
class DateTimeMarshaler
|
21
9
|
def initialize(opts = {})
|
22
10
|
@formatter = opts[:formatter] || Iso8601Formatter
|
@@ -45,6 +33,7 @@ module Aws
|
|
45
33
|
end
|
46
34
|
|
47
35
|
private
|
36
|
+
|
48
37
|
def _format(raw_value)
|
49
38
|
case raw_value
|
50
39
|
when nil
|
@@ -66,7 +55,6 @@ module Aws
|
|
66
55
|
datetime.iso8601
|
67
56
|
end
|
68
57
|
end
|
69
|
-
|
70
58
|
end
|
71
59
|
end
|
72
60
|
end
|
@@ -1,22 +1,10 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You may not
|
4
|
-
# use this file except in compliance with the License. A copy of the License is
|
5
|
-
# located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is distributed on
|
10
|
-
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
11
|
-
# or implied. See the License for the specific language governing permissions
|
12
|
-
# and limitations under the License.
|
1
|
+
# frozen_string_literal: true
|
13
2
|
|
14
3
|
require 'time'
|
15
4
|
|
16
5
|
module Aws
|
17
6
|
module Record
|
18
7
|
module Marshalers
|
19
|
-
|
20
8
|
class EpochTimeMarshaler
|
21
9
|
def initialize(opts = {})
|
22
10
|
@use_local_time = opts[:use_local_time] ? true : false
|
@@ -62,7 +50,6 @@ module Aws
|
|
62
50
|
end
|
63
51
|
end
|
64
52
|
end
|
65
|
-
|
66
53
|
end
|
67
54
|
end
|
68
55
|
end
|
@@ -1,23 +1,10 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You may not
|
4
|
-
# use this file except in compliance with the License. A copy of the License is
|
5
|
-
# located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is distributed on
|
10
|
-
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
11
|
-
# or implied. See the License for the specific language governing permissions
|
12
|
-
# and limitations under the License.
|
1
|
+
# frozen_string_literal: true
|
13
2
|
|
14
3
|
module Aws
|
15
4
|
module Record
|
16
5
|
module Marshalers
|
17
|
-
|
18
6
|
class FloatMarshaler
|
19
|
-
def initialize(opts = {})
|
20
|
-
end
|
7
|
+
def initialize(opts = {}); end
|
21
8
|
|
22
9
|
def type_cast(raw_value)
|
23
10
|
case raw_value
|
@@ -28,9 +15,7 @@ module Aws
|
|
28
15
|
when Float
|
29
16
|
raw_value
|
30
17
|
else
|
31
|
-
raw_value.respond_to?(:to_f) ?
|
32
|
-
raw_value.to_f :
|
33
|
-
raw_value.to_s.to_f
|
18
|
+
raw_value.respond_to?(:to_f) ? raw_value.to_f : raw_value.to_s.to_f
|
34
19
|
end
|
35
20
|
end
|
36
21
|
|
@@ -46,7 +31,6 @@ module Aws
|
|
46
31
|
end
|
47
32
|
end
|
48
33
|
end
|
49
|
-
|
50
34
|
end
|
51
35
|
end
|
52
36
|
end
|
@@ -1,23 +1,10 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You may not
|
4
|
-
# use this file except in compliance with the License. A copy of the License is
|
5
|
-
# located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is distributed on
|
10
|
-
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
11
|
-
# or implied. See the License for the specific language governing permissions
|
12
|
-
# and limitations under the License.
|
1
|
+
# frozen_string_literal: true
|
13
2
|
|
14
3
|
module Aws
|
15
4
|
module Record
|
16
5
|
module Marshalers
|
17
|
-
|
18
6
|
class IntegerMarshaler
|
19
|
-
def initialize(opts = {})
|
20
|
-
end
|
7
|
+
def initialize(opts = {}); end
|
21
8
|
|
22
9
|
def type_cast(raw_value)
|
23
10
|
case raw_value
|
@@ -28,9 +15,7 @@ module Aws
|
|
28
15
|
when Integer
|
29
16
|
raw_value
|
30
17
|
else
|
31
|
-
raw_value.respond_to?(:to_i) ?
|
32
|
-
raw_value.to_i :
|
33
|
-
raw_value.to_s.to_i
|
18
|
+
raw_value.respond_to?(:to_i) ? raw_value.to_i : raw_value.to_s.to_i
|
34
19
|
end
|
35
20
|
end
|
36
21
|
|
@@ -46,7 +31,6 @@ module Aws
|
|
46
31
|
end
|
47
32
|
end
|
48
33
|
end
|
49
|
-
|
50
34
|
end
|
51
35
|
end
|
52
36
|
end
|