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 +4 -4
- data/README.md +8 -0
- data/lib/tiny_dyno/tables.rb +21 -5
- data/lib/tiny_dyno/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: 4233ad83e5671f5fdda79619898709274424d179
|
4
|
+
data.tar.gz: 8b9ac3bb7cf279cefdc3c9e6f4c0932ebfa55832
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
|
data/lib/tiny_dyno/tables.rb
CHANGED
@@ -4,9 +4,8 @@ module TinyDyno
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
class_attribute :
|
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
|
data/lib/tiny_dyno/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|