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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71c633a9843c158c8a2968cc38a7d9af4f37d46f
4
- data.tar.gz: aed5352784c95c484d8fb57052721e9f96027035
3
+ metadata.gz: 23c37a26af08080a7a7a5a045c2859ae90c61420
4
+ data.tar.gz: 707325a83015c5bd925e774a1f61d5cdad8b4514
5
5
  SHA512:
6
- metadata.gz: 2b38678f9b5430385630d843bd26e3928dde6774f7ec2015ece75c5605bd601c4169f267a5c0bfd725d2bdff18151bf9861a120ab06537a4134110a22a44425f
7
- data.tar.gz: 01f8f00d068f6d9813ad5bc17582aa0c98747cd8729bc84d0a45c129cc3b14816e69bf76c51659e272b828f451862fc2a66b95f9dfb024a9fbb0eee9505d003a
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
- if (value = attribute.to_store(read_attribute(attribute.name)))
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
@@ -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
- attrs_to_update.merge!({
252
- k => {
253
- :value => attr_with_type(k,v).values.last,
254
- :action => "PUT"
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,
@@ -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['CLASS'].constantize.dynamo_table(:novalidate => true).delete(options)
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
@@ -1,5 +1,5 @@
1
1
  module Toy
2
2
  module Dynamo
3
- VERSION = "0.0.10"
3
+ VERSION = "0.0.11"
4
4
  end
5
5
  end
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.10
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-06 00:00:00.000000000 Z
11
+ date: 2013-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler