tiny_dyno 0.1.3 → 0.1.4

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: 4c28225700e74215ab38264798338459a755b819
4
- data.tar.gz: 7a9a91dd03e2cc1e2f444d1f3546f6d1b11732e2
3
+ metadata.gz: 4233ad83e5671f5fdda79619898709274424d179
4
+ data.tar.gz: 8b9ac3bb7cf279cefdc3c9e6f4c0932ebfa55832
5
5
  SHA512:
6
- metadata.gz: 76fe2cb0803f904f02af620ba3e6a8d01654319e5ae9b50d1eb5206f1688ec3530cdc8522e454c427722821d0377e7c474fdd8b2df2f6ad75fecc530907be389
7
- data.tar.gz: 6482ffb737d0fb35580f2277ac68f20304fefa9eb01ab31e8849b71bc3608652761129c634fa3c761c80948dd93495e85ba70b10e627cfd0e99d0268b30833de
6
+ metadata.gz: 6dc493c7cc647ed82b523d767e21382993ec363f832549f162db52cc6113972741ae0049481c288c3e135404000559b50e854d8ae3bc32976b7129386e84419e
7
+ data.tar.gz: 8d83ed0137f861c1647df1997bfdd81bef41efae93ca64388ba4b086903f4ee3bededde812f16025d7f06f28174e8c6be5c9473e3a9d8b77893ef2f98788df7d
data/README.md CHANGED
@@ -84,6 +84,7 @@ Or install it yourself as:
84
84
  ```
85
85
 
86
86
  require 'tiny_dyno'
87
+
87
88
  class Person
88
89
  include TinyDyno::Document
89
90
 
@@ -95,6 +96,8 @@ class Person
95
96
 
96
97
  end
97
98
 
99
+ Person.create_table / Person.create_table!
100
+
98
101
  require 'fabrication'
99
102
 
100
103
  Fabricator(:person) do
@@ -119,3 +122,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
119
122
 
120
123
  Bug reports and pull requests are welcome on GitHub at https://github.com/RataWorks/tiny_dyno.
121
124
 
125
+ Please ensure documentation updates, test cases etc. are included for any pull requests
126
+
127
+ For feature requests of currently unsupported DynamodB operations, please provide a raw, working usage example as example specification.
128
+
129
+
@@ -4,9 +4,8 @@ module TinyDyno
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- class_attribute :table_name, :provisioned_throughput
7
+ class_attribute :provisioned_throughput
8
8
 
9
- self.table_name = self.name.to_s.downcase
10
9
  self.provisioned_throughput ||= {
11
10
  read_capacity_units: 100,
12
11
  write_capacity_units: 100,
@@ -16,6 +15,10 @@ module TinyDyno
16
15
 
17
16
  module ClassMethods
18
17
 
18
+ def table_name
19
+ self.name.to_s.downcase
20
+ end
21
+
19
22
  class << self
20
23
 
21
24
  # Stores the provided block to be run when the option name specified is
@@ -54,19 +57,31 @@ module TinyDyno
54
57
  end
55
58
 
56
59
  # Send the actual table creation to the DynamoDB API
60
+ # and expect no table to be present
57
61
  # @example Create the table for the class
58
- # Person.create_table
62
+ # Person.create_table!
59
63
  # @return [ true ] If the operation succeeded
60
- def create_table
64
+ def create_table!
61
65
  raise InvalidTableDefinition.new "#{ self.name } has invalid table configuration" unless model_table_config_is_valid?
62
66
  TinyDyno::Adapter.create_table(create_table_request)
63
67
  end
64
68
 
69
+
70
+ # Soft Create Request,
71
+ # which will accept that a table may already exist
72
+ # @example Create the table for the class
73
+ # @return [ true ] If the operation succeeded <or> the table was already created
74
+ def create_table
75
+ if TinyDyno::Adapter.table_exists?(table_name: self.table_name)
76
+ return true
77
+ end
78
+ raise InvalidTableDefinition.new "#{ self.name } has invalid table configuration" unless model_table_config_is_valid?
79
+ TinyDyno::Adapter.create_table(create_table_request)
80
+ end
65
81
  # Request the table to be deleted
66
82
  # @example Delete the table for the class
67
83
  # Person.delete_table
68
84
  # @return [ true ] If the operation succeeded
69
-
70
85
  def delete_table
71
86
  TinyDyno::Adapter.delete_table(table_name: self.table_name)
72
87
  end
@@ -94,5 +109,6 @@ module TinyDyno
94
109
  }
95
110
  end
96
111
  end
112
+
97
113
  end
98
114
  end
@@ -1,3 +1,3 @@
1
1
  module TinyDyno
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_dyno
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Gerschner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-22 00:00:00.000000000 Z
11
+ date: 2015-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler