toy-dynamo 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/toy/dynamo/extensions/float.rb +13 -0
- data/lib/toy/dynamo/querying.rb +2 -2
- data/lib/toy/dynamo/table.rb +14 -13
- data/lib/toy/dynamo/version.rb +1 -1
- data/lib/toy/dynamo.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a979022e1dc25fa3a291046f2740f298d841964
|
4
|
+
data.tar.gz: d26220e83e7b162126a8e80298609950bc8997fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b942b853e9b412acf05208360f1fa8bbbf4a0b6ba7d0f480cd1d4ab9f141cdc850f7d085538ff9af15158745b692051af76810c4fbefac1f1016667d2301fcc
|
7
|
+
data.tar.gz: 7655f959d6dd0e993427b717c482557053b9f4ccb4533d7f3de7ce5c950c0f9042516b0a28aeb7e9fee204bb4dcdb366b7295c280caebac52e61d1af1e41f3c8
|
data/lib/toy/dynamo/querying.rb
CHANGED
@@ -67,8 +67,8 @@ module Toy
|
|
67
67
|
results = adapter.batch_read(keys, options)
|
68
68
|
results[:responses][dynamo_table.table_schema[:table_name]].each do |result|
|
69
69
|
attrs = Response.strip_attr_types(result)
|
70
|
-
if dynamo_table.range_keys.present?
|
71
|
-
(results_map[attrs[dynamo_table.hash_key[:attribute_name]]] ||= {})[attrs[
|
70
|
+
if dynamo_table.range_keys.present? && primary_range_key = dynamo_table.range_keys.find{|rk| rk[:primary_range_key] }
|
71
|
+
(results_map[attrs[dynamo_table.hash_key[:attribute_name]]] ||= {})[attrs[primary_range_key[:attribute_name]]] = load(attrs[dynamo_table.hash_key[:attribute_name]], attrs)
|
72
72
|
else
|
73
73
|
results_map[attrs[dynamo_table.hash_key[:attribute_name]]] = load(attrs[dynamo_table.hash_key[:attribute_name]], attrs)
|
74
74
|
end
|
data/lib/toy/dynamo/table.rb
CHANGED
@@ -71,6 +71,7 @@ module Toy
|
|
71
71
|
@hash_key = key_schema_attr
|
72
72
|
else
|
73
73
|
(@range_keys ||= []) << key_schema_attr.merge(:primary_range_key => true)
|
74
|
+
@primary_range_key = key_schema_attr.merge(:primary_range_key => true)
|
74
75
|
end
|
75
76
|
end
|
76
77
|
|
@@ -212,7 +213,7 @@ module Toy
|
|
212
213
|
if options[:select].is_a?(Array)
|
213
214
|
attrs_to_select = [options[:select].map(&:to_s)].flatten
|
214
215
|
attrs_to_select << @hash_key[:attribute_name]
|
215
|
-
attrs_to_select << primary_range_key[:attribute_name] if @
|
216
|
+
attrs_to_select << @primary_range_key[:attribute_name] if @primary_range_key
|
216
217
|
query_request.merge!({
|
217
218
|
:select => QUERY_SELECT[:specific],
|
218
219
|
:attributes_to_get => attrs_to_select.uniq
|
@@ -236,7 +237,7 @@ module Toy
|
|
236
237
|
keys_request = []
|
237
238
|
keys.each do |k|
|
238
239
|
key_request = {}
|
239
|
-
if @
|
240
|
+
if @primary_range_key
|
240
241
|
hash_value = k[:hash_value]
|
241
242
|
else
|
242
243
|
raise ArgumentError, "expected keys to be in the form of ['hash key here'] for table with no range keys" if hash_value.is_a?(Hash)
|
@@ -244,10 +245,10 @@ module Toy
|
|
244
245
|
end
|
245
246
|
raise ArgumentError, "every key must include a :hash_value" if hash_value.blank?
|
246
247
|
key_request[@hash_key[:attribute_name]] = { @hash_key[:attribute_type] => hash_value.to_s }
|
247
|
-
if @
|
248
|
+
if @primary_range_key
|
248
249
|
range_value = k[:range_value]
|
249
250
|
raise ArgumentError, "every key must include a :range_value" if range_value.blank?
|
250
|
-
key_request[primary_range_key[:attribute_name]] = { primary_range_key[:attribute_type] => range_value.to_s }
|
251
|
+
key_request[@primary_range_key[:attribute_name]] = { @primary_range_key[:attribute_type] => range_value.to_s }
|
251
252
|
end
|
252
253
|
keys_request << key_request
|
253
254
|
end
|
@@ -274,18 +275,18 @@ module Toy
|
|
274
275
|
@hash_key[:attribute_type] => hash_key_value.to_s
|
275
276
|
}
|
276
277
|
}
|
277
|
-
if @
|
278
|
-
range_key_value = attributes[primary_range_key[:attribute_name]]
|
278
|
+
if @primary_range_key
|
279
|
+
range_key_value = attributes[@primary_range_key[:attribute_name]]
|
279
280
|
raise ArgumentError, "range_key was not provided to the write command" if range_key_value.blank?
|
280
281
|
key_request.merge!({
|
281
|
-
primary_range_key[:attribute_name] => {
|
282
|
-
primary_range_key[:attribute_type] =>
|
282
|
+
@primary_range_key[:attribute_name] => {
|
283
|
+
@primary_range_key[:attribute_type] => range_key_value.to_s
|
283
284
|
}
|
284
285
|
})
|
285
286
|
end
|
286
287
|
attrs_to_update = {}
|
287
288
|
attributes.each_pair do |k,v|
|
288
|
-
next if primary_range_key && k == primary_range_key[:attribute_name]
|
289
|
+
next if @primary_range_key && k == @primary_range_key[:attribute_name]
|
289
290
|
if v.blank?
|
290
291
|
attrs_to_update.merge!({ k => { :action => "DELETE" } })
|
291
292
|
else
|
@@ -327,11 +328,11 @@ module Toy
|
|
327
328
|
@hash_key[:attribute_type] => hash_key_value.to_s
|
328
329
|
}
|
329
330
|
}
|
330
|
-
if @
|
331
|
+
if @primary_range_key
|
331
332
|
raise ArgumentError, "range_key was not provided to the delete_item command" if options[:range_value].blank?
|
332
333
|
key_request.merge!({
|
333
|
-
primary_range_key[:attribute_name] => {
|
334
|
-
primary_range_key[:attribute_type] => options[:range_value].to_s
|
334
|
+
@primary_range_key[:attribute_name] => {
|
335
|
+
@primary_range_key[:attribute_type] => options[:range_value].to_s
|
335
336
|
}
|
336
337
|
})
|
337
338
|
end
|
@@ -380,7 +381,7 @@ module Toy
|
|
380
381
|
if options[:select].is_a?(Array)
|
381
382
|
attrs_to_select = [options[:select].map(&:to_s)].flatten
|
382
383
|
attrs_to_select << @hash_key[:attribute_name]
|
383
|
-
attrs_to_select << primary_range_key[:attribute_name] if @
|
384
|
+
attrs_to_select << @primary_range_key[:attribute_name] if @primary_range_key
|
384
385
|
scan_request.merge!({
|
385
386
|
:select => QUERY_SELECT[:specific],
|
386
387
|
:attributes_to_get => attrs_to_select.uniq
|
data/lib/toy/dynamo/version.rb
CHANGED
data/lib/toy/dynamo.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toy-dynamo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cary Dunn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- lib/toy/dynamo/extensions/array.rb
|
102
102
|
- lib/toy/dynamo/extensions/boolean.rb
|
103
103
|
- lib/toy/dynamo/extensions/date.rb
|
104
|
+
- lib/toy/dynamo/extensions/float.rb
|
104
105
|
- lib/toy/dynamo/extensions/hash.rb
|
105
106
|
- lib/toy/dynamo/extensions/set.rb
|
106
107
|
- lib/toy/dynamo/extensions/symbol.rb
|