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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +335 -0
  3. data/LICENSE +202 -0
  4. data/VERSION +1 -0
  5. data/lib/aws-record/record/attribute.rb +9 -21
  6. data/lib/aws-record/record/attributes.rb +68 -78
  7. data/lib/aws-record/record/batch.rb +13 -12
  8. data/lib/aws-record/record/batch_read.rb +5 -2
  9. data/lib/aws-record/record/batch_write.rb +1 -12
  10. data/lib/aws-record/record/buildable_search.rb +33 -28
  11. data/lib/aws-record/record/client_configuration.rb +10 -21
  12. data/lib/aws-record/record/dirty_tracking.rb +30 -44
  13. data/lib/aws-record/record/errors.rb +1 -13
  14. data/lib/aws-record/record/item_collection.rb +5 -16
  15. data/lib/aws-record/record/item_data.rb +4 -18
  16. data/lib/aws-record/record/item_operations.rb +86 -93
  17. data/lib/aws-record/record/key_attributes.rb +1 -14
  18. data/lib/aws-record/record/marshalers/boolean_marshaler.rb +2 -16
  19. data/lib/aws-record/record/marshalers/date_marshaler.rb +1 -15
  20. data/lib/aws-record/record/marshalers/date_time_marshaler.rb +2 -14
  21. data/lib/aws-record/record/marshalers/epoch_time_marshaler.rb +1 -14
  22. data/lib/aws-record/record/marshalers/float_marshaler.rb +3 -19
  23. data/lib/aws-record/record/marshalers/integer_marshaler.rb +3 -19
  24. data/lib/aws-record/record/marshalers/list_marshaler.rb +2 -16
  25. data/lib/aws-record/record/marshalers/map_marshaler.rb +2 -16
  26. data/lib/aws-record/record/marshalers/numeric_set_marshaler.rb +3 -16
  27. data/lib/aws-record/record/marshalers/string_marshaler.rb +2 -16
  28. data/lib/aws-record/record/marshalers/string_set_marshaler.rb +3 -16
  29. data/lib/aws-record/record/marshalers/time_marshaler.rb +1 -14
  30. data/lib/aws-record/record/model_attributes.rb +14 -35
  31. data/lib/aws-record/record/query.rb +7 -21
  32. data/lib/aws-record/record/secondary_indexes.rb +23 -42
  33. data/lib/aws-record/record/table_config.rb +52 -74
  34. data/lib/aws-record/record/table_migration.rb +43 -66
  35. data/lib/aws-record/record/transactions.rb +67 -38
  36. data/lib/aws-record/record/version.rb +2 -13
  37. data/lib/aws-record/record.rb +30 -49
  38. metadata +14 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1d49110ed24d748680a2fe7c1d124e5faa40c1ee224b6f20059cc3252dc8b27
4
- data.tar.gz: 4efe9261ad7642c172e267f4cec4b614f61f42e7c57970c7561b6eb51c6ac516
3
+ metadata.gz: 737cba9ded94a3d3785cda00b45989e7deee3592c53cae2f4a63a769f1ba3f55
4
+ data.tar.gz: 1f086b7c3958985bc57ca2a39b22255e88cee84fe0930118ad6c5b8ff78e3c2c
5
5
  SHA512:
6
- metadata.gz: 9d2d80ea4671ab80debef324a8f80b40cb41034b2a426c69d95db48d436d86f1f7c4d1c8458da363595c28de3254c0755d9956f78f3e25dcacea83d695c8cede
7
- data.tar.gz: ae7e17fb7b3fcd56a3e5f78c92da540bcceb5d4a3ec62ac70b95cf0eaefaedb89a5845b701d5b28eba0221294c6eb1f769800756017e04a812dd1a552dfd43ce
6
+ metadata.gz: 5cd823dc1edfe588f87d2b7f770a4fa25ca248a055940196264660b803bac3ecce4714f6fb5cb157e1d7d0a668b41bcade92de49851f87f336aaacc6406af167
7
+ data.tar.gz: 3174f0eb63e34a421b3cbe4c494f7c86ddf5a66e1da6e572351a294cbdfad89b4bd0a41197b7b569b67967e270fe57a9e8f5b07ddedb411d1225e27a0c958b9b
data/CHANGELOG.md ADDED
@@ -0,0 +1,335 @@
1
+ 2.11.0 (2023-06-02)
2
+ ------------------
3
+
4
+ * Feature - Improve User-Agent tracking and bump minimum DynamoDB version.
5
+
6
+ 2.10.1 (2023-01-17)
7
+ ------------------
8
+
9
+ * Issue - Set `Aws::Record::VERSION` constant from the `VERSION` file
10
+
11
+ 2.10.0 (2023-01-13)
12
+ ------------------
13
+
14
+ * Feature - Implement the `BatchGetItem` operation (#122)
15
+
16
+ 2.9.0 (2022-11-16)
17
+ ------------------
18
+
19
+ * Feature - Add support for inheritance. Aws Record models can now be extended using standard ruby inheritance (#80).
20
+
21
+ 2.8.0 (2022-10-12)
22
+ ------------------
23
+
24
+ * Feature - Add support for atomic counter (#144)
25
+
26
+ 2.7.0 (2021-10-28)
27
+ ------------------
28
+
29
+ * Feature - Implement the `BatchWriteItem` operation (#119)
30
+
31
+ 2.6.1 (2021-08-10)
32
+ ------------------
33
+
34
+ * Issue - Fix FrozenError on BuildableSearch (#115)
35
+
36
+ 2.6.0 (2021-05-13)
37
+ ------------------
38
+
39
+ * Feature - Add support for on-demand-billing for table migrations (#94)
40
+
41
+ 2.5.0 (2020-10-13)
42
+ ------------------
43
+
44
+ * Feature - `Aws::Record::BuildableSearch` - Support queries yielding heterogeneous results using `multi_model_filter` (#107)
45
+
46
+ 2.4.1 (2020-05-29)
47
+ ------------------
48
+
49
+ * Issue - Allow symbols for database_attribute_name
50
+ * Issue - Correctly allow lambda/proc for default_value
51
+
52
+ 2.4.0 (2019-07-16)
53
+ ------------------
54
+
55
+ * Feature - Aws::Record::BuildableSearch - Adds support for query and scan builders using substitution expressions. This allows for streamlined and expressive queries and scans using aws-record.
56
+
57
+ 2.3.0 (2019-02-08)
58
+ ------------------
59
+
60
+ * Feature - Aws::Record::Transactions - Adds support for transactional find and transactional get requests. You can learn more about these new APIs in the [documentation](https://docs.aws.amazon.com/awssdkrubyrecord/api/Aws/Record/Transactions.html).
61
+
62
+ 2.2.0 (2018-12-05)
63
+ ------------------
64
+
65
+ * Feature - Aws::Record::TableConfig - Adds support for the "PAY_PER_REQUEST" billing mode in table configurations.
66
+
67
+ 2.1.2 (2018-11-15)
68
+ ------------------
69
+
70
+ * Issue - Aws::Record::Marshalers::EpochTimeMarshaler - Fixed a bug where epoch time objects didn't properly marshal from database entries.
71
+
72
+ 2.1.1 (2018-07-10)
73
+ ------------------
74
+
75
+ * Feature - Aws::Record::TableConfig - Adds `:ttl_attribute` to the TableConfig DSL. When used with `epoch_time_attr` attributes or other attributes stored as epoch time, your TableConfig migrations will enable TTL on your DynamoDB table, and will use your specified attribute as the TTL attribute.
76
+
77
+ * Feature - Aws::Record::Marshalers::EpochTimeMarshaler - Adds the `epoch_time_attr`, which behaves much like `time_attr` except the Amazon DynamoDB storage type is numeric, and the serialized value is epoch seconds.
78
+
79
+ 2.1.0 (2018-06-25)
80
+ ------------------
81
+
82
+ * Feature - Aws::Record - Add the `persisted?`, `new_record?`, and `destroyed?` methods to `Aws::Record`, which supports use cases where you'd like to see if a record has just been newly initialized, or has been deleted or was a preexisting record retrieved from DynamoDB. Note that these methods are present in `ActiveModel::Model` so you should require that module before `Aws::Record`
83
+
84
+ * Feature - Aws::Record - Add the `assign_attributes`, `update`, and `update!` methods to `Aws::Record` which supports the use case where the user might want to mass assign or update a records attributes by hash. `update!` also ensures that a `ValidationError` is thrown on an invalid update
85
+
86
+ * Upgrading - If you already include `ActiveModel::Model` on your models the new `persisted?`, `new_record?` and `destroyed?` methods will not function properly unless you include `ActiveModel::Model` before `Aws::Record`. Additionally, new methods could lead to collisions if you happened to have attributes such as `:update` or `:assign_attributes`. In such a case, you would want to version lock below `2.1.0`, or use the `:database_attribute_name` property and change your attribute name in code.
87
+
88
+ 2.0.2 (2018-06-08)
89
+ ------------------
90
+
91
+ * Feature - Aws::Record::Marshalers::TimeMarshaler - Adds the `time_attr` method to AWS Record models, which uses `Time` as the underlying type.
92
+
93
+ 2.0.1 (2017-10-27)
94
+ ------------------
95
+
96
+ * Feature - Aws::Record::ItemCollection - Add the `#page` and `#last_evaluated_key` methods to `Aws::Record::ItemCollection`. This helps to support use cases where you'd like to control the result set size with the `:limit` parameter, or if you want to expose pagination capabilities to an outside caller, for example a list-type operation exposed in a web API.
97
+
98
+ 2.0.0 (2017-08-29)
99
+ ------------------
100
+
101
+ * Upgrading - Aws::Record - Support version 3 of the AWS SDK for Ruby. This is being released as major version 2 of `aws-record`, though the APIs remain the same. Do note, however, that we've changed our SDK dependency to only depend on `aws-sdk-dynamodb`. This means that if you were depending on other service clients transitively via `aws-record`, you will need to add dependencies on the appropriate service gems when upgrading.
102
+
103
+ 1.1.1 (2017-06-16)
104
+ ------------------
105
+
106
+ * Feature - Support lambdas for default attribute values.
107
+
108
+ ```ruby
109
+ date_attr :date, default_value -> { Date.today }
110
+ ```
111
+
112
+ * Issue - An attribute's default_value could be modified and carried over to
113
+ new instances of the model. With this change, default values are deep copied,
114
+ and are hydrated at item creation to ensure correct persistence of mutable
115
+ objects.
116
+
117
+ See [related GitHub issue #69](https://github.com/aws/aws-sdk-ruby-record/issues/69)
118
+
119
+ 1.1.0 (2017-04-21)
120
+ ------------------
121
+
122
+ * Feature - Aws::Record::TableConfig - A declarative way to describe
123
+ configuration for your Amazon DynamoDB tables, with smart migrations based on
124
+ the current remote state. More details in the documentation.
125
+
126
+ * Issue - Aws::Record::TableMigration - Legacy table migrations could have
127
+ issues with global secondary indexes if a table was deleted and recreated
128
+ multiple times.
129
+
130
+ See [related GitHub issue #64](https://github.com/aws/aws-sdk-ruby-record/issues/64).
131
+
132
+ 1.0.3 (2016-12-19)
133
+ ------------------
134
+
135
+ * Feature - Aws::Record::ItemOperations - Adds the `find_with_opts` class method
136
+ to model instances, which allows users to pass in both the key (as in `find`)
137
+ and parameters which are to be passed through to the underlying
138
+ `Aws::DynamoDB::Client#get_item` call.
139
+
140
+ 1.0.2 (2016-12-02)
141
+ ------------------
142
+
143
+ * Issue - Aws::Record::ItemOperations - Fixes an issue where update operations
144
+ which consist of only `REMOVE` expressions failed due to an empty
145
+ `:expression_attribute_values` map. The fix makes the presence of that map
146
+ conditional on the existance of valid values.
147
+
148
+ 1.0.1 (2016-08-24)
149
+ ------------------
150
+
151
+ * Issue - Aws::Record::ItemCollection - Fixes a faulty `#empty?` implementation,
152
+ which could return `false` for a response which is, in fact, empty.
153
+
154
+ 1.0.0 (2016-08-15)
155
+ ------------------
156
+
157
+ * Issue - Aws::Record - Fixes the `#table_exists?` and `#provisioned_throughput`
158
+ methods, which could fail if called before `#table_name`.
159
+
160
+ 1.0.0.pre.10 (2016-08-03)
161
+ ------------------
162
+
163
+ * Feature - Aws::Record - Refactored tracking of model attributes, key attributes,
164
+ and item data to use internal classes over module composition. Dirty tracking is
165
+ also handled more consistently across attributes, and turning on/off of dirty
166
+ tracking is only possible at the model level (not for individual attributes).
167
+
168
+ 1.0.0.pre.9 (2016-07-22)
169
+ ------------------
170
+
171
+ * Feature - Aws::Record::Attribute - Added support for default values at the attribute
172
+ level.
173
+
174
+ * Feature - Aws::Record::Marshalers - Removed the marshalers in the `Aws::Attributes`
175
+ namespace, replacing them with instantiated marshaler objects. This enables
176
+ more functionality in marshalers such as the Date/DateTime marshalers.
177
+
178
+ * Feature - Aws::Record::DirtyTracking - Improves dirty tracking by adding
179
+ support for tracking mutations of attribute value objects. This feature is on
180
+ by default for the "collection" types: `:list_attr`, `:map_attr`,
181
+ `:string_set_attr`, and `:numeric_set_attr`.
182
+
183
+ Before this feature, the `#save` method's default behavior of running an
184
+ update call for dirty attributes only could cause problems for users of
185
+ collection attributes. As many of them are commonly manipulated using mutable
186
+ state, the underlying "clean" version of the objects would be modified and the
187
+ updated object would not be recognized as dirty, and therefore would not be
188
+ updated at all unless explicitly marked as dirty or through a force put.
189
+
190
+ ```ruby
191
+ class Model
192
+ include Aws::Record
193
+ string_attr :uuid, hash_key: true
194
+ list_attr :collection
195
+ end
196
+
197
+ item = Model.new(uuid: SecureRandom.uuid, collection: [1,2,3])
198
+ item.clean! # As if loaded from the database, to demonstrate the new tracking.
199
+ item.dirty? # => false
200
+ item.collection << 4 # In place mutation of the "collection" array.
201
+ item.dirty? # => true (Previous versions would not recognize this as dirty.
202
+ item.save # Would call Aws::DynamoDB::Client#update_item for :collection only.
203
+ ```
204
+
205
+ Note that this feature is implemented using deep copies of collection objects
206
+ in memory, so there is a potential memory/performance hit in exchange for the
207
+ added accuracy. As such, mutation tracking can be explicitly turned off at the
208
+ attribute level or at the full model level, if desired.
209
+
210
+ ```ruby
211
+ # Note that the disabling of mutation tracking is redundant in this example,
212
+ # for illustration purposes.
213
+ class Model
214
+ include Aws::Record
215
+ disable_mutation_tracking # For turning off mutation at the model level.
216
+ string_attr :uuid, hash_key: true
217
+ list_attr :collection, mutation_tracking: false # Turn off at attr level.
218
+ end
219
+ ```
220
+
221
+ 1.0.0.pre.8 (2016-05-19)
222
+ ------------------
223
+
224
+ * Feature - Aws::Record - Adds the ability to set initial attribute values when
225
+ calling `#initialize`. Additionally, can call `update` on a model to directly
226
+ call `Aws::DynamoDB::Client#update_item`.
227
+
228
+ 1.0.0.pre.7 (2016-04-21)
229
+ ------------------
230
+
231
+ * Upgrading - Aws::Record - This release includes changes to validation and
232
+ to the `#save` and `#save!` methods. With this release, the validation hooks
233
+ in `Aws::Record::Attribute` have been removed. Additionally, `#save` will
234
+ resume raising exceptions on client errors. However, `#save` and `#save!`
235
+ will attempt to call `#valid?` if defined on the model, and will return false
236
+ or raise as appropriate if that method is defined and returns false.
237
+
238
+ As a part of this change, we've removed the built in `#valid?` and `#errors`
239
+ methods. If you were a user of those, consider bringing your own validation
240
+ library such as `ActiveModel::Validations`.
241
+
242
+ * Issue - Aws::Record - Removes `#valid?` and `#errors` methods, which caused a
243
+ conflict with the ability to bring your own validation library such as
244
+ `ActiveModel::Validations`. Added tests as an example and to test
245
+ compatibility.
246
+
247
+ 1.0.0.pre.6 (2016-04-19)
248
+ ------------------
249
+
250
+ * Feature - Aws::Record::Attributes - Improves default marshaling behavior for
251
+ set types. Now, if your object responds to `:to_set`, such as an Array, it
252
+ will automatically be marshaled to a set type when persisted.
253
+
254
+ 1.0.0.pre.5 (2016-04-19)
255
+ ------------------
256
+
257
+ * Upgrading - Aws::Record - The conditional put/update logic added to `#save`
258
+ and `#save!` is not backwards compatible in some cases. For example, the
259
+ following code would work in previous versions, but not in this version:
260
+
261
+ ```ruby
262
+ item = Model.new # Assume :id is the hash key, there is no range key.
263
+ item.id = 1
264
+ item.content = "First write."
265
+ item.save
266
+
267
+ smash = Model.new
268
+ smash.id = 1
269
+ smash.content = "Second write."
270
+ smash.save # false, and populates the errors array.
271
+ smash.save(force: true) # This will skip the conditional check and work.
272
+
273
+ updatable = Model.find(id: 1)
274
+ updatable.content = "Update write."
275
+ updatable.save # This works and uses an update client call.
276
+ ```
277
+
278
+ If you want to maintain previous behavior of unconditional puts, add the
279
+ `force: true` option to your `#save` calls. However, this risks overwriting
280
+ unmodeled attributes, or attributes excluded from your projection. But, the
281
+ option is available for you to use.
282
+
283
+ * Upgrading - Aws::Record - The split of the `#save` method into `#save` and
284
+ `#save!` breaks when your code is expecting `#save` to raise exceptions.
285
+ `#save` will return false on a failed write and populate an `errors` array.
286
+ If you wish to raise exceptions on failed save attempts, use the `#save!`
287
+ method.
288
+
289
+ * Feature - Aws::Record - Adds logic to determine if `#save` and `#save!` calls
290
+ should use `Aws::DynamoDB::Client#put_item` or
291
+ `Aws::DynamoDB::Client#update_item`, depending on which item attributes are
292
+ marked as dirty. `#put_item` calls are also made conditional on the key not
293
+ existing, so accidental overwrites can be prevented. Old behavior of
294
+ unconditional `#put_item` calls can be done using the `force: true` parameter.
295
+
296
+ * Feature - Aws::Record - Separates the `#save` method into `#save` and
297
+ `#save!`. `#save!` will raise any errors that occur during persistence, while
298
+ `#save` will populate an errors array and cause `#valid?` calls on the item to
299
+ return `false`.
300
+
301
+ * Issue - Aws::Record - Changed how default table names are generated. In the
302
+ past, the default table name could not handle class names that included
303
+ modules. Now, module namespaces are appended to the default table name. This
304
+ should not affect any existing model classes, as previously any affected
305
+ models would have failed to create a table in DynamoDB.
306
+
307
+ 1.0.0.pre.4 (2016-02-11)
308
+ ------------------
309
+
310
+ * Feature - Aws::Record::DirtyTracking - `Aws::Record` items will now keep track
311
+ of "dirty" changes from database state. The DirtyTracking module provides a
312
+ set of helper methods to handle dirty attributes.
313
+
314
+ 1.0.0.pre.3 (2016-02-10)
315
+ ------------------
316
+
317
+ * Feature - Aws::Record - Support for additional marshaled types, such as lists,
318
+ maps, and string/numeric sets.
319
+
320
+ 1.0.0.pre.2 (2016-02-04)
321
+ ------------------
322
+
323
+ * Feature - Aws::Record - Provides a low-level interface for the client `#query`
324
+ and `#scan` methods. Query and Scan results are surfaces as an enumerable
325
+ collection of `Aws::Record` items.
326
+
327
+ * Feature - Aws::Record - Support for adding global secondary indexes and local
328
+ secondary indexes to your model classes. Built-in support for creating these
329
+ indexes at table creation time.
330
+
331
+ 1.0.0.pre.1 (2015-12-23)
332
+ ------------------
333
+
334
+ * Feature - Aws::Record - Initial development release of the `aws-record` gem.
335
+ Includes basic table and item functionality for CRUD operations.
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2.11.0
@@ -1,26 +1,13 @@
1
- # Copyright 2015-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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
  # This class provides helper methods for +Aws::Record+ attributes. These
18
6
  # include marshalers for type casting of item attributes, the Amazon
19
7
  # DynamoDB type for use in certain table and item operation calls, and the
20
8
  # ability to define a database name that is separate from the name used
21
9
  # within the model class and item instances.
22
10
  class Attribute
23
-
24
11
  attr_reader :name, :database_name, :dynamodb_type
25
12
 
26
13
  # @param [Symbol] name Name of the attribute. It should be a name that is
@@ -45,10 +32,11 @@ module Aws
45
32
  # nil values will be ignored and not persisted. By default, is false.
46
33
  # @option options [Object] :default_value Optional attribute used to
47
34
  # define a "default value" to be used if the attribute's value on an
48
- # item is nil or not set at persistence time.
35
+ # item is nil or not set at persistence time. Additionally, lambda can
36
+ # be used as a default value.
49
37
  def initialize(name, options = {})
50
38
  @name = name
51
- @database_name = (options[:database_attribute_name] || name).to_s
39
+ @database_name = (options[:database_attribute_name] || name).to_s
52
40
  @dynamodb_type = options[:dynamodb_type]
53
41
  @marshaler = options[:marshaler] || DefaultMarshaler
54
42
  @persist_nil = options[:persist_nil]
@@ -79,8 +67,8 @@ module Aws
79
67
  @marshaler.serialize(cast_value)
80
68
  end
81
69
 
82
- # @return [Boolean] true if this attribute will actively persist nil
83
- # values, false otherwise. Default: false
70
+ # @return [Boolean] +true+ if this attribute will actively persist nil
71
+ # values, +false+ otherwise. Default: +false+
84
72
  def persist_nil?
85
73
  @persist_nil ? true : false
86
74
  end
@@ -100,6 +88,7 @@ module Aws
100
88
  end
101
89
 
102
90
  private
91
+
103
92
  def _deep_copy(obj)
104
93
  Marshal.load(Marshal.dump(obj))
105
94
  end
@@ -107,17 +96,16 @@ module Aws
107
96
  def _is_lambda?(obj)
108
97
  obj.respond_to?(:call)
109
98
  end
110
-
111
99
  end
112
100
 
113
101
  # This is an identity marshaler, which performs no changes for type casting
114
102
  # or serialization. It is generally not recommended for use.
115
103
  module DefaultMarshaler
116
- def self.type_cast(raw_value, options = {})
104
+ def self.type_cast(raw_value, _options = {})
117
105
  raw_value
118
106
  end
119
107
 
120
- def self.serialize(raw_value, options = {})
108
+ def self.serialize(raw_value, _options = {})
121
109
  raw_value
122
110
  end
123
111
  end