aws-record 2.7.0 → 2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +330 -0
- data/LICENSE +202 -0
- data/VERSION +1 -0
- data/lib/aws-record/record/attribute.rb +5 -15
- data/lib/aws-record/record/attributes.rb +161 -32
- data/lib/aws-record/record/batch.rb +99 -35
- data/lib/aws-record/record/batch_read.rb +186 -0
- data/lib/aws-record/record/batch_write.rb +9 -14
- data/lib/aws-record/record/buildable_search.rb +4 -2
- data/lib/aws-record/record/client_configuration.rb +13 -14
- data/lib/aws-record/record/dirty_tracking.rb +1 -12
- data/lib/aws-record/record/errors.rb +1 -12
- data/lib/aws-record/record/item_collection.rb +2 -13
- data/lib/aws-record/record/item_data.rb +1 -12
- data/lib/aws-record/record/item_operations.rb +47 -12
- data/lib/aws-record/record/key_attributes.rb +1 -12
- data/lib/aws-record/record/marshalers/boolean_marshaler.rb +1 -12
- data/lib/aws-record/record/marshalers/date_marshaler.rb +1 -12
- data/lib/aws-record/record/marshalers/date_time_marshaler.rb +1 -12
- data/lib/aws-record/record/marshalers/epoch_time_marshaler.rb +1 -12
- data/lib/aws-record/record/marshalers/float_marshaler.rb +1 -12
- data/lib/aws-record/record/marshalers/integer_marshaler.rb +1 -12
- data/lib/aws-record/record/marshalers/list_marshaler.rb +1 -12
- data/lib/aws-record/record/marshalers/map_marshaler.rb +1 -12
- data/lib/aws-record/record/marshalers/numeric_set_marshaler.rb +1 -12
- data/lib/aws-record/record/marshalers/string_marshaler.rb +1 -12
- data/lib/aws-record/record/marshalers/string_set_marshaler.rb +1 -12
- data/lib/aws-record/record/marshalers/time_marshaler.rb +1 -12
- data/lib/aws-record/record/model_attributes.rb +8 -12
- data/lib/aws-record/record/query.rb +1 -12
- data/lib/aws-record/record/secondary_indexes.rb +24 -12
- data/lib/aws-record/record/table_config.rb +1 -12
- data/lib/aws-record/record/table_migration.rb +1 -12
- data/lib/aws-record/record/transactions.rb +39 -7
- data/lib/aws-record/record/version.rb +2 -13
- data/lib/aws-record/record.rb +100 -20
- data/lib/aws-record.rb +2 -12
- metadata +8 -4
@@ -1,26 +1,17 @@
|
|
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
|
class BatchWrite
|
17
6
|
# @param [Aws::DynamoDB::Client] client the DynamoDB SDK client.
|
18
|
-
def initialize(
|
19
|
-
@client = client
|
7
|
+
def initialize(opts = {})
|
8
|
+
@client = opts[:client]
|
20
9
|
end
|
21
10
|
|
22
11
|
# Append a +PutItem+ operation to a batch write request.
|
23
12
|
#
|
13
|
+
# See {Batch.write} for example usage.
|
14
|
+
#
|
24
15
|
# @param [Aws::Record] record a model class that includes {Aws::Record}.
|
25
16
|
def put(record)
|
26
17
|
table_name, params = record_put_params(record)
|
@@ -30,6 +21,7 @@ module Aws
|
|
30
21
|
|
31
22
|
# Append a +DeleteItem+ operation to a batch write request.
|
32
23
|
#
|
24
|
+
# See {Batch.write} for example usage.
|
33
25
|
# @param [Aws::Record] record a model class that includes {Aws::Record}.
|
34
26
|
def delete(record)
|
35
27
|
table_name, params = record_delete_params(record)
|
@@ -39,6 +31,7 @@ module Aws
|
|
39
31
|
|
40
32
|
# Perform a +batch_write_item+ request.
|
41
33
|
#
|
34
|
+
# See {Batch.write} for example usage.
|
42
35
|
# @return [Aws::Record::BatchWrite] an instance that provides access to
|
43
36
|
# unprocessed items and allows for retries.
|
44
37
|
def execute!
|
@@ -49,6 +42,7 @@ module Aws
|
|
49
42
|
|
50
43
|
# Indicates if all items have been processed.
|
51
44
|
#
|
45
|
+
# See {Batch.write} for example usage.
|
52
46
|
# @return [Boolean] +true+ if +unprocessed_items+ is empty, +false+
|
53
47
|
# otherwise
|
54
48
|
def complete?
|
@@ -58,6 +52,7 @@ module Aws
|
|
58
52
|
# Returns all +DeleteItem+ and +PutItem+ operations that have not yet been
|
59
53
|
# processed successfully.
|
60
54
|
#
|
55
|
+
# See {Batch.write} for example usage.
|
61
56
|
# @return [Hash] All operations that have not yet successfully completed.
|
62
57
|
def unprocessed_items
|
63
58
|
operations
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Aws
|
2
4
|
module Record
|
3
5
|
class BuildableSearch
|
@@ -263,13 +265,13 @@ module Aws
|
|
263
265
|
|
264
266
|
def _next_name
|
265
267
|
ret = "#" + @next_name
|
266
|
-
@next_name.next
|
268
|
+
@next_name = @next_name.next
|
267
269
|
ret
|
268
270
|
end
|
269
271
|
|
270
272
|
def _next_value
|
271
273
|
ret = ":" + @next_value
|
272
|
-
@next_value.next
|
274
|
+
@next_value = @next_value.next
|
273
275
|
ret
|
274
276
|
end
|
275
277
|
end
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -26,6 +15,8 @@ module Aws
|
|
26
15
|
# in doubt, call this method to ensure your client is configured the way
|
27
16
|
# you want it to be configured.
|
28
17
|
#
|
18
|
+
# *Note*: {#dynamodb_client} is inherited from a parent model when
|
19
|
+
# +configure_client+ is explicitly specified in the parent.
|
29
20
|
# @param [Hash] opts the options you wish to use to create the client.
|
30
21
|
# Note that if you include the option +:client+, all other options
|
31
22
|
# will be ignored. See the documentation for other options in the
|
@@ -33,15 +24,23 @@ module Aws
|
|
33
24
|
# @option opts [Aws::DynamoDB::Client] :client allows you to pass in your
|
34
25
|
# own pre-configured client.
|
35
26
|
def configure_client(opts = {})
|
36
|
-
|
27
|
+
if self.class != Module && Aws::Record.extends_record?(self) && opts.empty? &&
|
28
|
+
self.superclass.instance_variable_get('@dynamodb_client')
|
29
|
+
@dynamodb_client = self.superclass.instance_variable_get('@dynamodb_client')
|
30
|
+
else
|
31
|
+
@dynamodb_client = _build_client(opts)
|
32
|
+
end
|
37
33
|
end
|
38
34
|
|
39
35
|
# Gets the
|
40
|
-
# {https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html}
|
36
|
+
# {https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html Client}
|
41
37
|
# instance that Transactions use. When called for the first time, if
|
42
38
|
# {#configure_client} has not yet been called, will configure a new
|
43
39
|
# client for you with default parameters.
|
44
40
|
#
|
41
|
+
# *Note*: +dynamodb_client+ is inherited from a parent model when
|
42
|
+
# {configure_client} is explicitly specified in the parent.
|
43
|
+
#
|
45
44
|
# @return [Aws::DynamoDB::Client] the Amazon DynamoDB client instance.
|
46
45
|
def dynamodb_client
|
47
46
|
@dynamodb_client ||= configure_client
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -54,7 +43,7 @@ module Aws
|
|
54
43
|
# match your search.
|
55
44
|
#
|
56
45
|
# @return [Array<Aws::Record>] an array of the record items found in the
|
57
|
-
# first page of
|
46
|
+
# first page of responses from the query or scan call.
|
58
47
|
def page
|
59
48
|
search_response = items
|
60
49
|
@last_evaluated_key = search_response.last_evaluated_key
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -354,6 +343,8 @@ module Aws
|
|
354
343
|
# Allows you to build a "check" expression for use in transactional
|
355
344
|
# write operations.
|
356
345
|
#
|
346
|
+
# See {Transactions.transact_write transact_write} for more info.
|
347
|
+
#
|
357
348
|
# @param [Hash] opts Options matching the :condition_check contents in
|
358
349
|
# the
|
359
350
|
# {https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#transact_write_items-instance_method Aws::DynamoDB::Client#transact_write_items}
|
@@ -381,6 +372,13 @@ module Aws
|
|
381
372
|
opts
|
382
373
|
end
|
383
374
|
|
375
|
+
# Used in {Transactions.transact_find}, which is a way to run
|
376
|
+
# transactional find across multiple DynamoDB items, including transactions
|
377
|
+
# which get items across multiple actual or virtual tables.
|
378
|
+
#
|
379
|
+
# This operation provide extra metadata used to marshal your items after retrieval.
|
380
|
+
#
|
381
|
+
# See {Transactions.transact_find transact_find} for more info and usage example.
|
384
382
|
def tfind_opts(opts)
|
385
383
|
opts = opts.dup
|
386
384
|
key = opts.delete(:key)
|
@@ -514,6 +512,43 @@ module Aws
|
|
514
512
|
end
|
515
513
|
end
|
516
514
|
|
515
|
+
|
516
|
+
# @example Usage Example
|
517
|
+
# class MyModel
|
518
|
+
# include Aws::Record
|
519
|
+
# integer_attr :id, hash_key: true
|
520
|
+
# string_attr :name, range_key: true
|
521
|
+
# end
|
522
|
+
#
|
523
|
+
# # returns a homogenous list of items
|
524
|
+
# foo_items = MyModel.find_all(
|
525
|
+
# [
|
526
|
+
# {id: 1, name: 'n1'},
|
527
|
+
# {id: 2, name: 'n2'}
|
528
|
+
# ])
|
529
|
+
#
|
530
|
+
# Provides support for the
|
531
|
+
# {https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#batch_get_item-instance_method
|
532
|
+
# Aws::DynamoDB::Client#batch_get_item} for your model.
|
533
|
+
#
|
534
|
+
# This method will take a list of keys and return an instance of +Aws::Record::BatchRead+
|
535
|
+
#
|
536
|
+
# See {Batch.read} for more details.
|
537
|
+
# @param [Array] keys an array of item key hashes you wish to search for.
|
538
|
+
# @return [Aws::Record::BatchRead] An instance that contains modeled items
|
539
|
+
# from the +BatchGetItem+ result and stores unprocessed keys to be
|
540
|
+
# manually processed later.
|
541
|
+
# @raise [Aws::Record::Errors::KeyMissing] if your param hashes do not
|
542
|
+
# include all the keys defined in model.
|
543
|
+
# @raise [ArgumentError] if the provided keys are a duplicate.
|
544
|
+
def find_all(keys)
|
545
|
+
Aws::Record::Batch.read do |db|
|
546
|
+
keys.each do |key|
|
547
|
+
db.find(self, key)
|
548
|
+
end
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
517
552
|
# @example Usage Example
|
518
553
|
# class MyModel
|
519
554
|
# include Aws::Record
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -1,15 +1,4 @@
|
|
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
|
|
@@ -1,15 +1,4 @@
|
|
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
|
|
@@ -1,15 +1,4 @@
|
|
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
|
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -1,15 +1,4 @@
|
|
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
|
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -32,6 +21,13 @@ module Aws
|
|
32
21
|
attribute
|
33
22
|
end
|
34
23
|
|
24
|
+
def register_superclass_attribute (name, attribute)
|
25
|
+
_new_attr_validation(name, attribute)
|
26
|
+
@attributes[name] = attribute.dup
|
27
|
+
@storage_attributes[attribute.database_name] = name
|
28
|
+
attribute
|
29
|
+
end
|
30
|
+
|
35
31
|
def attribute_for(name)
|
36
32
|
@attributes[name]
|
37
33
|
end
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -1,15 +1,4 @@
|
|
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
|
@@ -20,6 +9,17 @@ module Aws
|
|
20
9
|
sub_class.instance_variable_set("@local_secondary_indexes", {})
|
21
10
|
sub_class.instance_variable_set("@global_secondary_indexes", {})
|
22
11
|
sub_class.extend(SecondaryIndexesClassMethods)
|
12
|
+
if Aws::Record.extends_record?(sub_class)
|
13
|
+
inherit_indexes(sub_class)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def self.inherit_indexes(klass)
|
19
|
+
superclass_lsi = klass.superclass.instance_variable_get("@local_secondary_indexes").dup
|
20
|
+
superclass_gsi = klass.superclass.instance_variable_get("@global_secondary_indexes").dup
|
21
|
+
klass.instance_variable_set("@local_secondary_indexes", superclass_lsi)
|
22
|
+
klass.instance_variable_set("@global_secondary_indexes", superclass_gsi)
|
23
23
|
end
|
24
24
|
|
25
25
|
module SecondaryIndexesClassMethods
|
@@ -28,6 +28,8 @@ module Aws
|
|
28
28
|
# Secondary Indexes in the
|
29
29
|
# {http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LSI.html Amazon DynamoDB Developer Guide}.
|
30
30
|
#
|
31
|
+
# *Note*: {#local_secondary_indexes} is inherited from a parent model
|
32
|
+
# when +local_secondary_index+ is explicitly specified in the parent.
|
31
33
|
# @param [Symbol] name index name for this local secondary index
|
32
34
|
# @param [Hash] opts
|
33
35
|
# @option opts [Symbol] :range_key the range key used by this local
|
@@ -46,6 +48,8 @@ module Aws
|
|
46
48
|
# Global Secondary Indexes in the
|
47
49
|
# {http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html Amazon DynamoDB Developer Guide}.
|
48
50
|
#
|
51
|
+
# *Note*: {#global_secondary_indexes} is inherited from a parent model
|
52
|
+
# when +global_secondary_index+ is explicitly specified in the parent.
|
49
53
|
# @param [Symbol] name index name for this global secondary index
|
50
54
|
# @param [Hash] opts
|
51
55
|
# @option opts [Symbol] :hash_key the hash key used by this global
|
@@ -60,12 +64,20 @@ module Aws
|
|
60
64
|
global_secondary_indexes[name] = opts
|
61
65
|
end
|
62
66
|
|
67
|
+
# Returns hash of local secondary index names to the index’s attributes.
|
68
|
+
#
|
69
|
+
# *Note*: +local_secondary_indexes+ is inherited from a parent model when {#local_secondary_index}
|
70
|
+
# is explicitly specified in the parent.
|
63
71
|
# @return [Hash] hash of local secondary index names to the index's
|
64
72
|
# attributes.
|
65
73
|
def local_secondary_indexes
|
66
74
|
@local_secondary_indexes
|
67
75
|
end
|
68
76
|
|
77
|
+
# Returns hash of global secondary index names to the index’s attributes.
|
78
|
+
#
|
79
|
+
# *Note*: +global_secondary_indexes+ is inherited from a parent model when {#global_secondary_index}
|
80
|
+
# is explicitly specified in the parent.
|
69
81
|
# @return [Hash] hash of global secondary index names to the index's
|
70
82
|
# attributes.
|
71
83
|
def global_secondary_indexes
|