toy-dynamo 0.0.10 → 0.0.11
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/persistence.rb +1 -3
- data/lib/toy/dynamo/table.rb +10 -6
- data/lib/toy/dynamo/tasks.rb +15 -4
- data/lib/toy/dynamo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23c37a26af08080a7a7a5a045c2859ae90c61420
|
4
|
+
data.tar.gz: 707325a83015c5bd925e774a1f61d5cdad8b4514
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 748c736f820ed06874cfb67d46e7c80a691f135eed405aca4dd70beaaab722219956e0ea30dd26296b38987364c1366426d8faf39bb21917092f9c9df3a1f084
|
7
|
+
data.tar.gz: 5879b51d25ffcf765f89a4f02fc90a0d3610a8870a76e968e15ebcf72a92f3932f803c085a7f3b840b9869e3e91b4494f0844975e6084e4c10007da347a39b58
|
@@ -15,9 +15,7 @@ module Toy
|
|
15
15
|
end
|
16
16
|
|
17
17
|
attributes_to_persist.each do |attribute|
|
18
|
-
|
19
|
-
attributes_with_values[attribute.persisted_name] = value
|
20
|
-
end
|
18
|
+
attributes_with_values[attribute.persisted_name] = attribute.to_store(read_attribute(attribute.name))
|
21
19
|
end
|
22
20
|
|
23
21
|
attributes_with_values
|
data/lib/toy/dynamo/table.rb
CHANGED
@@ -248,12 +248,16 @@ module Toy
|
|
248
248
|
attrs_to_update = {}
|
249
249
|
attributes.each_pair do |k,v|
|
250
250
|
next if @range_keys && k == range_key[:attribute_name]
|
251
|
-
|
252
|
-
k => {
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
251
|
+
if v.blank?
|
252
|
+
attrs_to_update.merge!({ k => { :action => "DELETE" } })
|
253
|
+
else
|
254
|
+
attrs_to_update.merge!({
|
255
|
+
k => {
|
256
|
+
:value => attr_with_type(k,v).values.last,
|
257
|
+
:action => "PUT"
|
258
|
+
}
|
259
|
+
})
|
260
|
+
end
|
257
261
|
end
|
258
262
|
update_item_request = {
|
259
263
|
:table_name => options[:table_name] || self.table_name,
|
data/lib/toy/dynamo/tasks.rb
CHANGED
@@ -4,18 +4,18 @@ namespace :ddb do
|
|
4
4
|
desc 'Create a DynamoDB table'
|
5
5
|
task :create => :environment do
|
6
6
|
raise "expected usage: rake ddb:create CLASS=User" unless ENV['CLASS']
|
7
|
+
options = {}
|
8
|
+
options.merge!(:table_name => ENV['TABLE']) if ENV['TABLE']
|
7
9
|
if ENV["CLASS"] == "all"
|
8
10
|
Toy::Dynamo::Config.included_models.each do |klass|
|
9
11
|
puts "Creating table for #{klass}..."
|
10
12
|
begin
|
11
|
-
klass.dynamo_table(:novalidate => true).create
|
13
|
+
klass.dynamo_table(:novalidate => true).create(options)
|
12
14
|
rescue Exception => e
|
13
15
|
puts "Could not create table! #{e.inspect}"
|
14
16
|
end
|
15
17
|
end
|
16
18
|
else
|
17
|
-
options = {}
|
18
|
-
options.merge!(:table_name => ENV['TABLE']) if ENV['TABLE']
|
19
19
|
ENV['CLASS'].constantize.dynamo_table(:novalidate => true).create(options)
|
20
20
|
end
|
21
21
|
end
|
@@ -35,6 +35,17 @@ namespace :ddb do
|
|
35
35
|
raise "expected usage: rake ddb:destroy CLASS=User" unless ENV['CLASS']
|
36
36
|
options = {}
|
37
37
|
options.merge!(:table_name => ENV['TABLE']) if ENV['TABLE']
|
38
|
-
ENV[
|
38
|
+
if ENV["CLASS"] == "all"
|
39
|
+
Toy::Dynamo::Config.included_models.each do |klass|
|
40
|
+
puts "Destroying table for #{klass}..."
|
41
|
+
begin
|
42
|
+
klass.dynamo_table(:novalidate => true).delete(options)
|
43
|
+
rescue Exception => e
|
44
|
+
puts "Could not create table! #{e.inspect}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
else
|
48
|
+
ENV['CLASS'].constantize.dynamo_table(:novalidate => true).delete(options)
|
49
|
+
end
|
39
50
|
end
|
40
51
|
end
|
data/lib/toy/dynamo/version.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.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cary Dunn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|