aws-record 1.0.2 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6c46aec6c7a749fe6428fd36e7fa5bc8e205988
4
- data.tar.gz: 91de72e195aa41c91e5804c6a48e6ba04e4f035b
3
+ metadata.gz: 1ad49e4e5f6ac03a577a97f00f2312c37dfbe3ed
4
+ data.tar.gz: f5bf877eb339d5206f24f3c26e78adefdd08ff30
5
5
  SHA512:
6
- metadata.gz: 62a8c0327dde967851fc04bf89e42621fe05f59138aab1cdd084b230beb756d7178b18d107145737bbb1984ac08afdbbd87446fca6101a74f17895316e1d68ab
7
- data.tar.gz: 2c74f91a4fa0f0e233ecc3c8dad80843faada5222bceff1f898c6acd1032131726abf7c3a1fe0c28a17f213e1ccde034df4d33b6461c01a3bc40b188f1d7cf97
6
+ metadata.gz: e816d83098562cf009da4c44520605260f22440d6f384fd55c94e30e47b789fa1106cda1b50c4a47fc314ee9b83c254e6e781edb464f46035fb63e42ab347c28
7
+ data.tar.gz: 6c501354f1de3358c4ee475ad8c8dd017d5e6a9b748af57b570114781d1b614a3f4ba27b9ea3944b2a0c36559ee76586ad2cfb92ae91feb46a9f1a46674aec04
@@ -237,21 +237,52 @@ module Aws
237
237
  # @raise [Aws::Record::Errors::KeyMissing] if your option parameters do
238
238
  # not include all table keys.
239
239
  def find(opts)
240
- key = {}
240
+ find_with_opts(key: opts)
241
+ end
242
+
243
+ # @example Usage Example
244
+ # class MyModel
245
+ # include Aws::Record
246
+ # integer_attr :id, hash_key: true
247
+ # string_attr :name, range_key: true
248
+ # end
249
+ #
250
+ # MyModel.find_with_opts(
251
+ # key: { id: 1, name: "First" },
252
+ # consistent_read: true
253
+ # )
254
+ #
255
+ # Note that +#find_with_opts+ will pass through all options other than
256
+ # +:key+ unaltered to the underlying +Aws::DynamoDB::Client#get_item+
257
+ # request. You should ensure that you have an aws-sdk gem version which
258
+ # supports the options you are including, and avoid adding options not
259
+ # recognized by the underlying client to avoid runtime exceptions.
260
+ #
261
+ # @param [Hash] opts Options to pass through to the DynamoDB #get_item
262
+ # request. The +:key+ option is a special case where attributes are
263
+ # serialized and translated for you similar to the #find method.
264
+ # @option opts [Hash] :key attribute-value pairs for the key you wish to
265
+ # search for.
266
+ # @return [Aws::Record] builds and returns an instance of your model.
267
+ # @raise [Aws::Record::Errors::KeyMissing] if your option parameters do
268
+ # not include all table keys.
269
+ def find_with_opts(opts)
270
+ key = opts.delete(:key)
271
+ request_key = {}
241
272
  @keys.keys.each_value do |attr_sym|
242
- unless opts[attr_sym]
273
+ unless key[attr_sym]
243
274
  raise Errors::KeyMissing.new(
244
- "Missing required key #{attr_sym} in #{opts}"
275
+ "Missing required key #{attr_sym} in #{key}"
245
276
  )
246
277
  end
247
278
  attr_name = attributes.storage_name_for(attr_sym)
248
- key[attr_name] = attributes.attribute_for(attr_sym).
249
- serialize(opts[attr_sym])
279
+ request_key[attr_name] = attributes.attribute_for(attr_sym).
280
+ serialize(key[attr_sym])
250
281
  end
251
282
  request_opts = {
252
283
  table_name: table_name,
253
- key: key
254
- }
284
+ key: request_key
285
+ }.merge(opts)
255
286
  resp = dynamodb_client.get_item(request_opts)
256
287
  if resp.item.nil?
257
288
  nil
@@ -13,6 +13,6 @@
13
13
 
14
14
  module Aws
15
15
  module Record
16
- VERSION = '1.0.2'
16
+ VERSION = '1.0.3'
17
17
  end
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-02 00:00:00.000000000 Z
11
+ date: 2016-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-resources