ocean-dynamo 0.3.12 → 0.3.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +35 -33
  3. data/lib/ocean-dynamo/version.rb +1 -1
  4. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78c329fb34c6009e6168abc0d4a8f8bd5a973de4
4
- data.tar.gz: 0acc91468d0d8a3a7773dd1dde5f63d3c330381e
3
+ metadata.gz: ff62cac1b81cd01f68f4d8be25004ae94c0afa14
4
+ data.tar.gz: f5fa8a4e8d8c7b86421a2ad977fd279136a08402
5
5
  SHA512:
6
- metadata.gz: 26850203ac5c1f3665bce77a2c14c33990e0355a84cc10163bd3275d56d9afcf33d03a0e766b7e3679e36aabd385311e1a5373da74f6543e1f7191f05f953b5a
7
- data.tar.gz: 810d9c6bab90781479716dccb02cd9390576ceedc06f883f16d155ea97f839323ff42a7ca3f83e0c208ce4ce86e369898a83b59c3f12befde20d2e7726e64f52
6
+ metadata.gz: d2296afae10ea96ca8eecdb5822878da60fbd2c20b293a868694f6167bfc95ddb9519153a8b1fb08bacc7ec2506a25c307aefc4cf01398e4486d17e01f568c9e
7
+ data.tar.gz: 02ec483b0b395f07e5213bc572cf57e30ad30cd420d0b9bf39fafbcb04198f391bb8b73603f22c1e6b98dc728d18e7491e1d84c72e0ecd0232ccabfe62fbb798
data/README.rdoc CHANGED
@@ -18,9 +18,9 @@ is of course based on ActiveModel.
18
18
 
19
19
  The attribute and persistence layer of OceanDynamo is modeled on that of ActiveRecord:
20
20
  there's +save+, +save!+, +create+, +update+, +update!+, +update_attributes+, +find_each+,
21
- and all the other methods you're used to. The design goal is always to implement as much
22
- of the ActiveRecord interface as possible, without compromising scalability. This makes the
23
- task of switching from SQL to no-SQL much easier.
21
+ +destroy_all+, +delete_all+ and all the other methods you're used to. The design goal
22
+ is always to implement as much of the ActiveRecord interface as possible, without
23
+ compromising scalability. This makes the task of switching from SQL to no-SQL much easier.
24
24
 
25
25
  Thanks to its structural similarity to ActiveRecord, OceanDynamo works with FactoryGirl.
26
26
  To facilitate testing, future versions will keep track of and delete instances after tests.
@@ -30,7 +30,9 @@ which means it will scale without limits.
30
30
 
31
31
  === Example
32
32
 
33
- The following example shows the syntax.
33
+ ==== Basic syntax
34
+
35
+ The following example shows the basic syntax for declaring a DynamoDB-based schema.
34
36
 
35
37
  class AsyncJob < OceanDynamo::Base
36
38
 
@@ -54,6 +56,8 @@ The following example shows the syntax.
54
56
 
55
57
  end
56
58
 
59
+ ==== Attributes
60
+
57
61
  Each attribute has a name, a type (+:string+, +:integer+, +:float+, +:datetime+, +:boolean+,
58
62
  or +:serialized+) where +:string+ is the default. Each attribute also optionally has a default
59
63
  value, which can be a Proc. The hash key attribute is by default +:id+ (overridden as +:uuid+ in
@@ -65,7 +69,9 @@ Sets are represented as arrays, may not contain duplicates and may not be empty.
65
69
  All attributes except the +:string+ type can take the value +nil+. Storing +nil+ for a string
66
70
  value will return the empty string, <tt>""</tt>.
67
71
 
68
- Also, dynamo_schema takes args and many options. Here's the full syntax:
72
+ ==== Schema args and options
73
+
74
+ +dynamo_schema+ takes args and many options. Here's the full syntax:
69
75
 
70
76
  dynamo_schema(
71
77
  table_hash_key = :id, # The name of the hash key attribute
@@ -85,7 +91,11 @@ Also, dynamo_schema takes args and many options. Here's the full syntax:
85
91
  ...
86
92
  end
87
93
 
88
- The following example shows how to set up a belongs_to relation:
94
+ === +belongs_to+
95
+
96
+ ==== Example
97
+
98
+ The following example shows how to set up a +belongs_to+ relation:
89
99
 
90
100
  class Parent < OceanDynamo::Base
91
101
  dynamo_schema do
@@ -106,38 +116,28 @@ The following example shows how to set up a belongs_to relation:
106
116
  belongs_to :parent
107
117
  end
108
118
 
109
- The +belongs_to+ declaration must follow after the +dynamo_schema+ attribute block.
110
-
111
-
112
- === Current State
113
-
114
- At the moment, OceanDynamo is fully usable as an ActiveModel and can be used by Rails
115
- controllers. Furthermore, OceanDynamo implements much of the infrastructure of ActiveRecord;
116
- for instance, +read_attribute+, +write_attribute+, and much of the control logic and
117
- parameters.
118
-
119
- +Model.all+ and +.count+ work as expected. +Model.find_each+ is also available.
120
-
121
- +belongs_to+ is now operational. The other side, +has_many+, is much simpler and should
122
- follow very soon (probably today).
119
+ ==== Restrictions
123
120
 
124
121
  Restrictions for +belongs_to+ tables:
125
122
  * The hash key must be specified and must not be +:id+.
126
123
  * The range key must not be specified at all.
127
124
  * +belongs_to+ can be specified only once in each class.
125
+ * +belongs_to+ must be placed after the +dynamo_schema+ attribute block.
128
126
 
129
127
  These restrictions allow OceanDynamo to implement the +has_many+ / +belongs_to+
130
128
  relation in a very efficient and massively scalable way.
131
129
 
130
+ ==== Implementation
131
+
132
132
  +belongs_to+ claims the range key and uses it to store its own UUID, which normally
133
133
  would be stored in the hash key attribute. Instead, the hash key attribute holds the
134
134
  UUID of the parent. We have thus reversed the roles of these two fields. As a result,
135
135
  all children have their parent UUID as their hash key, and their own UUID in their
136
136
  range key.
137
137
 
138
- This type of association is even more efficient than its ActiveRecord counterpart as
139
- it uses only the primary index of the child model for finds and scans in both directions
140
- of the +has_many+ / +belongs_to+ association.
138
+ This type of relation is even more efficient than its ActiveRecord counterpart as
139
+ it uses only the primary index of the child model in both directions of the
140
+ +has_many+ / +belongs_to+ association. No scans.
141
141
 
142
142
  Furthermore, since DynamoDB has powerful primary index searches involving substrings
143
143
  and matching, the fact that the range key is a string can be used to implement
@@ -149,24 +149,26 @@ which means that secondary indices won't be necessary for the vast majority of
149
149
  OceanDynamo use cases. This ultimately means reduced operational costs, as well as
150
150
  reduced complexity.
151
151
 
152
- +.has_belongs_to?+ returns true if the class has a belongs_to association.
153
-
154
- +.belongs_to_class returns the class of the belongs_to association, or false if none.
155
152
 
156
- +.find+ can now take an array arg.
153
+ === Current State
157
154
 
158
- +#hash_key+ and +#range_key+ readers added.
155
+ OceanDynamo is fully usable as an ActiveModel and can be used by Rails
156
+ controllers. OceanDynamo implements much of the infrastructure of ActiveRecord;
157
+ for instance, +read_attribute+, +write_attribute+, and much of the control logic and
158
+ parameters.
159
159
 
160
+ +belongs_to+ is now operational. The other side, +has_many+, is much simpler and should
161
+ follow very soon (probably today).
160
162
 
161
163
  === Future milestones
162
164
 
163
- After the +has_many+ / +belongs_to+ association, the +has_and_belongs_to_many+ assocation
164
- will be implemented.
165
+ * After the +has_many+ / +belongs_to+ association, the +has_and_belongs_to_many+ assocation
166
+ will be implemented.
165
167
 
166
- A generator to install the <tt>config/aws.yml</tt> file.
168
+ * A generator to install the <tt>config/aws.yml</tt> file.
167
169
 
168
- OceanDynamo will use association proxies to achieve the same kind of
169
- interface as ActiveRecord, e.g.: <code>blog_entry.comments.build(body: "Cool!").save!</code>
170
+ * OceanDynamo will use association proxies to achieve the same kind of
171
+ interface as ActiveRecord, e.g.: <code>blog_entry.comments.build(body: "Cool!").save!</code>
170
172
 
171
173
 
172
174
  === Current use
@@ -1,3 +1,3 @@
1
1
  module OceanDynamo
2
- VERSION = "0.3.12"
2
+ VERSION = "0.3.13"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean-dynamo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Bengtson
@@ -144,15 +144,15 @@ description: "== OceanDynamo\n\nOceanDynamo is a massively scalable Amazon Dynam
144
144
  and support methods. Ocean-dynamo follows this pattern closely and\nis of course
145
145
  based on ActiveModel.\n\nThe attribute and persistence layer of OceanDynamo is modeled
146
146
  on that of ActiveRecord:\nthere's +save+, +save!+, +create+, +update+, +update!+,
147
- +update_attributes+, +find_each+,\nand all the other methods you're used to. The
148
- design goal is always to implement as much \nas possible of the ActiveRecord interface,
149
- without sacrificing scalability. This makes the \ntask of switching from SQL to
150
- no-SQL much easier.\n\nThanks to its structural similarity to ActiveRecord, OceanDynamo
151
- works with FactoryGirl.\nTo facilitate testing, future versions will keep track
152
- of and delete instances after tests.\n\nOceanDynamo uses primary indices to retrieve
153
- related table items, \nwhich means it will scale without limits.\n\nSee also Ocean,
154
- a Rails framework for creating highly scalable SOAs in the cloud, in which\nocean-dynamo
155
- is used as a central component: http://wiki.oceanframework.net"
147
+ +update_attributes+, +find_each+,\n+destroy_all+, +delete_all+ and all the other
148
+ methods you're used to. The design goal \nis always to implement as much of the
149
+ ActiveRecord interface as possible, without \ncompromising scalability. This makes
150
+ the task of switching from SQL to no-SQL much easier.\n\nThanks to its structural
151
+ similarity to ActiveRecord, OceanDynamo works with FactoryGirl.\nTo facilitate testing,
152
+ future versions will keep track of and delete instances after tests.\n\nOceanDynamo
153
+ uses primary indices to retrieve related table items, \nwhich means it will scale
154
+ without limits.\n\nSee also Ocean, a Rails framework for creating highly scalable
155
+ SOAs in the cloud, in which\nocean-dynamo is used as a central component: http://wiki.oceanframework.net"
156
156
  email:
157
157
  - peter@peterbengtson.com
158
158
  executables: []