dynamoid 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/Dynamoid.gemspec +65 -3
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +6 -0
  4. data/README.markdown +117 -22
  5. data/Rakefile +22 -9
  6. data/VERSION +1 -1
  7. data/doc/.nojekyll +0 -0
  8. data/doc/Dynamoid.html +300 -0
  9. data/doc/Dynamoid/Adapter.html +1387 -0
  10. data/doc/Dynamoid/Adapter/AwsSdk.html +1561 -0
  11. data/doc/Dynamoid/Adapter/Local.html +1487 -0
  12. data/doc/Dynamoid/Associations.html +131 -0
  13. data/doc/Dynamoid/Associations/Association.html +1706 -0
  14. data/doc/Dynamoid/Associations/BelongsTo.html +339 -0
  15. data/doc/Dynamoid/Associations/ClassMethods.html +723 -0
  16. data/doc/Dynamoid/Associations/HasAndBelongsToMany.html +339 -0
  17. data/doc/Dynamoid/Associations/HasMany.html +339 -0
  18. data/doc/Dynamoid/Associations/HasOne.html +339 -0
  19. data/doc/Dynamoid/Components.html +202 -0
  20. data/doc/Dynamoid/Config.html +395 -0
  21. data/doc/Dynamoid/Config/Options.html +609 -0
  22. data/doc/Dynamoid/Criteria.html +131 -0
  23. data/doc/Dynamoid/Criteria/Chain.html +759 -0
  24. data/doc/Dynamoid/Criteria/ClassMethods.html +98 -0
  25. data/doc/Dynamoid/Document.html +512 -0
  26. data/doc/Dynamoid/Document/ClassMethods.html +581 -0
  27. data/doc/Dynamoid/Errors.html +118 -0
  28. data/doc/Dynamoid/Errors/DocumentNotValid.html +210 -0
  29. data/doc/Dynamoid/Errors/Error.html +130 -0
  30. data/doc/Dynamoid/Errors/InvalidField.html +133 -0
  31. data/doc/Dynamoid/Errors/MissingRangeKey.html +133 -0
  32. data/doc/Dynamoid/Fields.html +649 -0
  33. data/doc/Dynamoid/Fields/ClassMethods.html +264 -0
  34. data/doc/Dynamoid/Finders.html +128 -0
  35. data/doc/Dynamoid/Finders/ClassMethods.html +502 -0
  36. data/doc/Dynamoid/Indexes.html +308 -0
  37. data/doc/Dynamoid/Indexes/ClassMethods.html +351 -0
  38. data/doc/Dynamoid/Indexes/Index.html +1089 -0
  39. data/doc/Dynamoid/Persistence.html +653 -0
  40. data/doc/Dynamoid/Persistence/ClassMethods.html +568 -0
  41. data/doc/Dynamoid/Validations.html +399 -0
  42. data/doc/_index.html +439 -0
  43. data/doc/class_list.html +47 -0
  44. data/doc/css/common.css +1 -0
  45. data/doc/css/full_list.css +55 -0
  46. data/doc/css/style.css +322 -0
  47. data/doc/file.LICENSE.html +66 -0
  48. data/doc/file.README.html +279 -0
  49. data/doc/file_list.html +52 -0
  50. data/doc/frames.html +13 -0
  51. data/doc/index.html +279 -0
  52. data/doc/js/app.js +205 -0
  53. data/doc/js/full_list.js +173 -0
  54. data/doc/js/jquery.js +16 -0
  55. data/doc/method_list.html +1054 -0
  56. data/doc/top-level-namespace.html +105 -0
  57. data/lib/dynamoid.rb +2 -1
  58. data/lib/dynamoid/adapter.rb +77 -6
  59. data/lib/dynamoid/adapter/aws_sdk.rb +96 -16
  60. data/lib/dynamoid/adapter/local.rb +84 -15
  61. data/lib/dynamoid/associations.rb +53 -4
  62. data/lib/dynamoid/associations/association.rb +154 -26
  63. data/lib/dynamoid/associations/belongs_to.rb +32 -6
  64. data/lib/dynamoid/associations/has_and_belongs_to_many.rb +29 -3
  65. data/lib/dynamoid/associations/has_many.rb +30 -4
  66. data/lib/dynamoid/associations/has_one.rb +26 -3
  67. data/lib/dynamoid/components.rb +7 -5
  68. data/lib/dynamoid/config.rb +15 -2
  69. data/lib/dynamoid/config/options.rb +8 -0
  70. data/lib/dynamoid/criteria.rb +7 -2
  71. data/lib/dynamoid/criteria/chain.rb +55 -8
  72. data/lib/dynamoid/document.rb +68 -7
  73. data/lib/dynamoid/errors.rb +17 -2
  74. data/lib/dynamoid/fields.rb +44 -1
  75. data/lib/dynamoid/finders.rb +32 -6
  76. data/lib/dynamoid/indexes.rb +22 -2
  77. data/lib/dynamoid/indexes/index.rb +48 -7
  78. data/lib/dynamoid/persistence.rb +111 -51
  79. data/lib/dynamoid/validations.rb +36 -0
  80. data/spec/app/models/address.rb +2 -1
  81. data/spec/app/models/camel_case.rb +11 -0
  82. data/spec/app/models/magazine.rb +4 -1
  83. data/spec/app/models/sponsor.rb +3 -1
  84. data/spec/app/models/subscription.rb +5 -1
  85. data/spec/app/models/user.rb +10 -1
  86. data/spec/dynamoid/associations/association_spec.rb +67 -1
  87. data/spec/dynamoid/associations/belongs_to_spec.rb +16 -1
  88. data/spec/dynamoid/associations/has_and_belongs_to_many_spec.rb +7 -0
  89. data/spec/dynamoid/associations/has_many_spec.rb +14 -0
  90. data/spec/dynamoid/associations/has_one_spec.rb +10 -1
  91. data/spec/dynamoid/criteria_spec.rb +5 -1
  92. data/spec/dynamoid/document_spec.rb +23 -3
  93. data/spec/dynamoid/fields_spec.rb +10 -1
  94. data/spec/dynamoid/indexes/index_spec.rb +19 -0
  95. data/spec/dynamoid/persistence_spec.rb +24 -0
  96. data/spec/dynamoid/validations_spec.rb +36 -0
  97. metadata +105 -4
@@ -0,0 +1,581 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: Dynamoid::Document::ClassMethods
8
+
9
+ &mdash; Documentation by YARD 0.7.5
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ relpath = '../..';
19
+ if (relpath != '') relpath += '/';
20
+ </script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
25
+
26
+
27
+ </head>
28
+ <body>
29
+ <script type="text/javascript" charset="utf-8">
30
+ if (window.top.frames.main) document.body.className = 'frames';
31
+ </script>
32
+
33
+ <div id="header">
34
+ <div id="menu">
35
+
36
+ <a href="../../_index.html">Index (C)</a> &raquo;
37
+ <span class='title'><span class='object_link'><a href="../../Dynamoid.html" title="Dynamoid (module)">Dynamoid</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Document</a></span></span>
38
+ &raquo;
39
+ <span class="title">ClassMethods</span>
40
+
41
+
42
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
43
+ </div>
44
+
45
+ <div id="search">
46
+
47
+ <a id="class_list_link" href="#">Class List</a>
48
+
49
+ <a id="method_list_link" href="#">Method List</a>
50
+
51
+ <a id="file_list_link" href="#">File List</a>
52
+
53
+ </div>
54
+ <div class="clear"></div>
55
+ </div>
56
+
57
+ <iframe id="search_frame"></iframe>
58
+
59
+ <div id="content"><h1>Module: Dynamoid::Document::ClassMethods
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+ <dt class="r1 last">Defined in:</dt>
75
+ <dd class="r1 last">lib/dynamoid/document.rb</dd>
76
+
77
+ </dl>
78
+ <div class="clear"></div>
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+ <h2>
89
+ Instance Method Summary
90
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
91
+ </h2>
92
+
93
+ <ul class="summary">
94
+
95
+ <li class="public ">
96
+ <span class="summary_signature">
97
+
98
+ <a href="#build-instance_method" title="#build (instance method)">- (Dynamoid::Document) <strong>build</strong>(attrs = {}) </a>
99
+
100
+
101
+
102
+ </span>
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ <span class="summary_desc"><div class='inline'><p>Initialize a new object.</p>
112
+ </div></span>
113
+
114
+ </li>
115
+
116
+
117
+ <li class="public ">
118
+ <span class="summary_signature">
119
+
120
+ <a href="#create-instance_method" title="#create (instance method)">- (Dynamoid::Document) <strong>create</strong>(attrs = {}) </a>
121
+
122
+
123
+
124
+ </span>
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ <span class="summary_desc"><div class='inline'><p>Initialize a new object and immediately save it to the database.</p>
134
+ </div></span>
135
+
136
+ </li>
137
+
138
+
139
+ <li class="public ">
140
+ <span class="summary_signature">
141
+
142
+ <a href="#create%21-instance_method" title="#create! (instance method)">- (Dynamoid::Document) <strong>create!</strong>(attrs = {}) </a>
143
+
144
+
145
+
146
+ </span>
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+ <span class="summary_desc"><div class='inline'><p>Initialize a new object and immediately save it to the database.</p>
156
+ </div></span>
157
+
158
+ </li>
159
+
160
+
161
+ <li class="public ">
162
+ <span class="summary_signature">
163
+
164
+ <a href="#exists%3F-instance_method" title="#exists? (instance method)">- (Boolean) <strong>exists?</strong>(id) </a>
165
+
166
+
167
+
168
+ </span>
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+ <span class="summary_desc"><div class='inline'><p>Does this object exist?.</p>
178
+ </div></span>
179
+
180
+ </li>
181
+
182
+
183
+ </ul>
184
+
185
+
186
+
187
+
188
+ <div id="instance_method_details" class="method_details_list">
189
+ <h2>Instance Method Details</h2>
190
+
191
+
192
+ <div class="method_details first">
193
+ <p class="signature first" id="build-instance_method">
194
+
195
+ - (<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>) <strong>build</strong>(attrs = {})
196
+
197
+
198
+
199
+ </p><div class="docstring">
200
+ <div class="discussion">
201
+ <p>Initialize a new object.</p>
202
+
203
+
204
+ </div>
205
+ </div>
206
+ <div class="tags">
207
+ <h3>Parameters:</h3>
208
+ <ul class="param">
209
+
210
+ <li>
211
+
212
+ <span class='name'>attrs</span>
213
+
214
+
215
+ <span class='type'>(<tt>Hash</tt>)</span>
216
+
217
+
218
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
219
+
220
+
221
+ &mdash;
222
+ <div class='inline'><p>Attributes with which to create the object.</p>
223
+ </div>
224
+
225
+ </li>
226
+
227
+ </ul>
228
+
229
+ <h3>Returns:</h3>
230
+ <ul class="return">
231
+
232
+ <li>
233
+
234
+
235
+ <span class='type'>(<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>)</span>
236
+
237
+
238
+
239
+ &mdash;
240
+ <div class='inline'><p>the new document</p>
241
+ </div>
242
+
243
+ </li>
244
+
245
+ </ul>
246
+ <h3>Since:</h3>
247
+ <ul class="since">
248
+
249
+ <li>
250
+
251
+
252
+
253
+
254
+
255
+ <div class='inline'><p>0.2.0</p>
256
+ </div>
257
+
258
+ </li>
259
+
260
+ </ul>
261
+
262
+ </div><table class="source_code">
263
+ <tr>
264
+ <td>
265
+ <pre class="lines">
266
+
267
+
268
+ 53
269
+ 54
270
+ 55</pre>
271
+ </td>
272
+ <td>
273
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/document.rb', line 53</span>
274
+
275
+ <span class='kw'>def</span> <span class='id identifier rubyid_build'>build</span><span class='lparen'>(</span><span class='id identifier rubyid_attrs'>attrs</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
276
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_attrs'>attrs</span><span class='rparen'>)</span>
277
+ <span class='kw'>end</span></pre>
278
+ </td>
279
+ </tr>
280
+ </table>
281
+ </div>
282
+
283
+ <div class="method_details ">
284
+ <p class="signature " id="create-instance_method">
285
+
286
+ - (<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>) <strong>create</strong>(attrs = {})
287
+
288
+
289
+
290
+ </p><div class="docstring">
291
+ <div class="discussion">
292
+ <p>Initialize a new object and immediately save it to the database.</p>
293
+
294
+
295
+ </div>
296
+ </div>
297
+ <div class="tags">
298
+ <h3>Parameters:</h3>
299
+ <ul class="param">
300
+
301
+ <li>
302
+
303
+ <span class='name'>attrs</span>
304
+
305
+
306
+ <span class='type'>(<tt>Hash</tt>)</span>
307
+
308
+
309
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
310
+
311
+
312
+ &mdash;
313
+ <div class='inline'><p>Attributes with which to create the object.</p>
314
+ </div>
315
+
316
+ </li>
317
+
318
+ </ul>
319
+
320
+ <h3>Returns:</h3>
321
+ <ul class="return">
322
+
323
+ <li>
324
+
325
+
326
+ <span class='type'>(<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>)</span>
327
+
328
+
329
+
330
+ &mdash;
331
+ <div class='inline'><p>the saved document</p>
332
+ </div>
333
+
334
+ </li>
335
+
336
+ </ul>
337
+ <h3>Since:</h3>
338
+ <ul class="since">
339
+
340
+ <li>
341
+
342
+
343
+
344
+
345
+
346
+ <div class='inline'><p>0.2.0</p>
347
+ </div>
348
+
349
+ </li>
350
+
351
+ </ul>
352
+
353
+ </div><table class="source_code">
354
+ <tr>
355
+ <td>
356
+ <pre class="lines">
357
+
358
+
359
+ 23
360
+ 24
361
+ 25
362
+ 26
363
+ 27
364
+ 28
365
+ 29</pre>
366
+ </td>
367
+ <td>
368
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/document.rb', line 23</span>
369
+
370
+ <span class='kw'>def</span> <span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_attrs'>attrs</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
371
+ <span class='id identifier rubyid_obj'>obj</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_attrs'>attrs</span><span class='rparen'>)</span>
372
+ <span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid_run_callbacks'>run_callbacks</span><span class='lparen'>(</span><span class='symbol'>:create</span><span class='rparen'>)</span> <span class='kw'>do</span>
373
+ <span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
374
+ <span class='kw'>end</span>
375
+ <span class='id identifier rubyid_obj'>obj</span>
376
+ <span class='kw'>end</span></pre>
377
+ </td>
378
+ </tr>
379
+ </table>
380
+ </div>
381
+
382
+ <div class="method_details ">
383
+ <p class="signature " id="create!-instance_method">
384
+
385
+ - (<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>) <strong>create!</strong>(attrs = {})
386
+
387
+
388
+
389
+ </p><div class="docstring">
390
+ <div class="discussion">
391
+ <p>Initialize a new object and immediately save it to the database. Raise an exception if persistence failed.</p>
392
+
393
+
394
+ </div>
395
+ </div>
396
+ <div class="tags">
397
+ <h3>Parameters:</h3>
398
+ <ul class="param">
399
+
400
+ <li>
401
+
402
+ <span class='name'>attrs</span>
403
+
404
+
405
+ <span class='type'>(<tt>Hash</tt>)</span>
406
+
407
+
408
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
409
+
410
+
411
+ &mdash;
412
+ <div class='inline'><p>Attributes with which to create the object.</p>
413
+ </div>
414
+
415
+ </li>
416
+
417
+ </ul>
418
+
419
+ <h3>Returns:</h3>
420
+ <ul class="return">
421
+
422
+ <li>
423
+
424
+
425
+ <span class='type'>(<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>)</span>
426
+
427
+
428
+
429
+ &mdash;
430
+ <div class='inline'><p>the saved document</p>
431
+ </div>
432
+
433
+ </li>
434
+
435
+ </ul>
436
+ <h3>Since:</h3>
437
+ <ul class="since">
438
+
439
+ <li>
440
+
441
+
442
+
443
+
444
+
445
+ <div class='inline'><p>0.2.0</p>
446
+ </div>
447
+
448
+ </li>
449
+
450
+ </ul>
451
+
452
+ </div><table class="source_code">
453
+ <tr>
454
+ <td>
455
+ <pre class="lines">
456
+
457
+
458
+ 38
459
+ 39
460
+ 40
461
+ 41
462
+ 42
463
+ 43
464
+ 44</pre>
465
+ </td>
466
+ <td>
467
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/document.rb', line 38</span>
468
+
469
+ <span class='kw'>def</span> <span class='id identifier rubyid_create!'>create!</span><span class='lparen'>(</span><span class='id identifier rubyid_attrs'>attrs</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
470
+ <span class='id identifier rubyid_obj'>obj</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_attrs'>attrs</span><span class='rparen'>)</span>
471
+ <span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid_run_callbacks'>run_callbacks</span><span class='lparen'>(</span><span class='symbol'>:create</span><span class='rparen'>)</span> <span class='kw'>do</span>
472
+ <span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid_save!'>save!</span>
473
+ <span class='kw'>end</span>
474
+ <span class='id identifier rubyid_obj'>obj</span>
475
+ <span class='kw'>end</span></pre>
476
+ </td>
477
+ </tr>
478
+ </table>
479
+ </div>
480
+
481
+ <div class="method_details ">
482
+ <p class="signature " id="exists?-instance_method">
483
+
484
+ - (<tt>Boolean</tt>) <strong>exists?</strong>(id)
485
+
486
+
487
+
488
+ </p><div class="docstring">
489
+ <div class="discussion">
490
+ <p>Does this object exist?</p>
491
+
492
+
493
+ </div>
494
+ </div>
495
+ <div class="tags">
496
+ <h3>Parameters:</h3>
497
+ <ul class="param">
498
+
499
+ <li>
500
+
501
+ <span class='name'>id</span>
502
+
503
+
504
+ <span class='type'>(<tt>String</tt>)</span>
505
+
506
+
507
+
508
+ &mdash;
509
+ <div class='inline'><p>the id of the object</p>
510
+ </div>
511
+
512
+ </li>
513
+
514
+ </ul>
515
+
516
+ <h3>Returns:</h3>
517
+ <ul class="return">
518
+
519
+ <li>
520
+
521
+
522
+ <span class='type'>(<tt>Boolean</tt>)</span>
523
+
524
+
525
+
526
+ &mdash;
527
+ <div class='inline'><p>true/false</p>
528
+ </div>
529
+
530
+ </li>
531
+
532
+ </ul>
533
+ <h3>Since:</h3>
534
+ <ul class="since">
535
+
536
+ <li>
537
+
538
+
539
+
540
+
541
+
542
+ <div class='inline'><p>0.2.0</p>
543
+ </div>
544
+
545
+ </li>
546
+
547
+ </ul>
548
+
549
+ </div><table class="source_code">
550
+ <tr>
551
+ <td>
552
+ <pre class="lines">
553
+
554
+
555
+ 64
556
+ 65
557
+ 66</pre>
558
+ </td>
559
+ <td>
560
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/document.rb', line 64</span>
561
+
562
+ <span class='kw'>def</span> <span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
563
+ <span class='op'>!</span><span class='op'>!</span> <span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
564
+ <span class='kw'>end</span></pre>
565
+ </td>
566
+ </tr>
567
+ </table>
568
+ </div>
569
+
570
+ </div>
571
+
572
+ </div>
573
+
574
+ <div id="footer">
575
+ Generated on Tue Mar 27 17:53:06 2012 by
576
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
577
+ 0.7.5 (ruby-1.9.3).
578
+ </div>
579
+
580
+ </body>
581
+ </html>