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,131 @@
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::Associations
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 (A)</a> &raquo;
37
+ <span class='title'><span class='object_link'><a href="../Dynamoid.html" title="Dynamoid (module)">Dynamoid</a></span></span>
38
+ &raquo;
39
+ <span class="title">Associations</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::Associations
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+
68
+
69
+ <dt class="r1">Extended by:</dt>
70
+ <dd class="r1">ActiveSupport::Concern</dd>
71
+
72
+
73
+
74
+
75
+
76
+
77
+ <dt class="r2">Included in:</dt>
78
+ <dd class="r2"><span class='object_link'><a href="Components.html" title="Dynamoid::Components (module)">Components</a></span></dd>
79
+
80
+
81
+
82
+ <dt class="r1 last">Defined in:</dt>
83
+ <dd class="r1 last">lib/dynamoid/associations.rb<span class="defines">,<br />
84
+ lib/dynamoid/associations/has_one.rb,<br /> lib/dynamoid/associations/has_many.rb,<br /> lib/dynamoid/associations/belongs_to.rb,<br /> lib/dynamoid/associations/association.rb,<br /> lib/dynamoid/associations/has_and_belongs_to_many.rb</span>
85
+ </dd>
86
+
87
+ </dl>
88
+ <div class="clear"></div>
89
+
90
+ <h2>Overview</h2><div class="docstring">
91
+ <div class="discussion">
92
+ <p>The has and belongs to many association.</p>
93
+
94
+
95
+ </div>
96
+ </div>
97
+ <div class="tags">
98
+
99
+
100
+ </div><h2>Defined Under Namespace</h2>
101
+ <p class="children">
102
+
103
+
104
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Associations/Association.html" title="Dynamoid::Associations::Association (module)">Association</a></span>, <span class='object_link'><a href="Associations/ClassMethods.html" title="Dynamoid::Associations::ClassMethods (module)">ClassMethods</a></span>
105
+
106
+
107
+
108
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Associations/BelongsTo.html" title="Dynamoid::Associations::BelongsTo (class)">BelongsTo</a></span>, <span class='object_link'><a href="Associations/HasAndBelongsToMany.html" title="Dynamoid::Associations::HasAndBelongsToMany (class)">HasAndBelongsToMany</a></span>, <span class='object_link'><a href="Associations/HasMany.html" title="Dynamoid::Associations::HasMany (class)">HasMany</a></span>, <span class='object_link'><a href="Associations/HasOne.html" title="Dynamoid::Associations::HasOne (class)">HasOne</a></span>
109
+
110
+
111
+ </p>
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+ </div>
123
+
124
+ <div id="footer">
125
+ Generated on Tue Mar 27 17:53:06 2012 by
126
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
127
+ 0.7.5 (ruby-1.9.3).
128
+ </div>
129
+
130
+ </body>
131
+ </html>
@@ -0,0 +1,1706 @@
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::Associations::Association
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 (A)</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="../Associations.html" title="Dynamoid::Associations (module)">Associations</a></span></span>
38
+ &raquo;
39
+ <span class="title">Association</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::Associations::Association
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+
68
+
69
+
70
+
71
+ <dt class="r1">Includes:</dt>
72
+ <dd class="r1">Enumerable</dd>
73
+
74
+
75
+
76
+
77
+ <dt class="r2">Included in:</dt>
78
+ <dd class="r2"><span class='object_link'><a href="BelongsTo.html" title="Dynamoid::Associations::BelongsTo (class)">BelongsTo</a></span>, <span class='object_link'><a href="HasAndBelongsToMany.html" title="Dynamoid::Associations::HasAndBelongsToMany (class)">HasAndBelongsToMany</a></span>, <span class='object_link'><a href="HasMany.html" title="Dynamoid::Associations::HasMany (class)">HasMany</a></span>, <span class='object_link'><a href="HasOne.html" title="Dynamoid::Associations::HasOne (class)">HasOne</a></span></dd>
79
+
80
+
81
+
82
+ <dt class="r1 last">Defined in:</dt>
83
+ <dd class="r1 last">lib/dynamoid/associations/association.rb</dd>
84
+
85
+ </dl>
86
+ <div class="clear"></div>
87
+
88
+
89
+
90
+
91
+
92
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
93
+ <ul class="summary">
94
+
95
+ <li class="public ">
96
+ <span class="summary_signature">
97
+
98
+ <a href="#name-instance_method" title="#name (instance method)">- (Object) <strong>name</strong> </a>
99
+
100
+
101
+
102
+ </span>
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+ <span class="summary_desc"><div class='inline'><p>Returns the value of attribute name.</p>
115
+ </div></span>
116
+
117
+ </li>
118
+
119
+
120
+ <li class="public ">
121
+ <span class="summary_signature">
122
+
123
+ <a href="#options-instance_method" title="#options (instance method)">- (Object) <strong>options</strong> </a>
124
+
125
+
126
+
127
+ </span>
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+ <span class="summary_desc"><div class='inline'><p>Returns the value of attribute options.</p>
140
+ </div></span>
141
+
142
+ </li>
143
+
144
+
145
+ <li class="public ">
146
+ <span class="summary_signature">
147
+
148
+ <a href="#query-instance_method" title="#query (instance method)">- (Object) <strong>query</strong> </a>
149
+
150
+
151
+
152
+ </span>
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+ <span class="summary_desc"><div class='inline'><p>Returns the value of attribute query.</p>
165
+ </div></span>
166
+
167
+ </li>
168
+
169
+
170
+ <li class="public ">
171
+ <span class="summary_signature">
172
+
173
+ <a href="#source-instance_method" title="#source (instance method)">- (Object) <strong>source</strong> </a>
174
+
175
+
176
+
177
+ </span>
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+ <span class="summary_desc"><div class='inline'><p>Returns the value of attribute source.</p>
190
+ </div></span>
191
+
192
+ </li>
193
+
194
+
195
+ </ul>
196
+
197
+
198
+
199
+
200
+
201
+ <h2>
202
+ Instance Method Summary
203
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
204
+ </h2>
205
+
206
+ <ul class="summary">
207
+
208
+ <li class="public ">
209
+ <span class="summary_signature">
210
+
211
+ <a href="#%3C%3C-instance_method" title="#&lt;&lt; (instance method)">- (Dynamoid::Document) <strong>&lt;&lt;</strong>(object) </a>
212
+
213
+
214
+
215
+ </span>
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+ <span class="summary_desc"><div class='inline'><p>Add an object or array of objects to an association.</p>
225
+ </div></span>
226
+
227
+ </li>
228
+
229
+
230
+ <li class="public ">
231
+ <span class="summary_signature">
232
+
233
+ <a href="#create-instance_method" title="#create (instance method)">- (Dynamoid::Document) <strong>create</strong>(attributes = {}) </a>
234
+
235
+
236
+
237
+ </span>
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+ <span class="summary_desc"><div class='inline'><p>Create a new instance of the target class and add it directly to the association.</p>
247
+ </div></span>
248
+
249
+ </li>
250
+
251
+
252
+ <li class="public ">
253
+ <span class="summary_signature">
254
+
255
+ <a href="#create%21-instance_method" title="#create! (instance method)">- (Dynamoid::Document) <strong>create!</strong>(attributes = {}) </a>
256
+
257
+
258
+
259
+ </span>
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+ <span class="summary_desc"><div class='inline'><p>Create a new instance of the target class and add it directly to the association.</p>
269
+ </div></span>
270
+
271
+ </li>
272
+
273
+
274
+ <li class="public ">
275
+ <span class="summary_signature">
276
+
277
+ <a href="#delete-instance_method" title="#delete (instance method)">- (Dynamoid::Document) <strong>delete</strong>(object) </a>
278
+
279
+
280
+
281
+ </span>
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+ <span class="summary_desc"><div class='inline'><p>Deletes an object or array of objects from the association.</p>
291
+ </div></span>
292
+
293
+ </li>
294
+
295
+
296
+ <li class="public ">
297
+ <span class="summary_signature">
298
+
299
+ <a href="#delete_all-instance_method" title="#delete_all (instance method)">- (Object) <strong>delete_all</strong> </a>
300
+
301
+
302
+
303
+ </span>
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+ <span class="summary_desc"><div class='inline'><p>Deletes all members of the association and removes them from the association.</p>
313
+ </div></span>
314
+
315
+ </li>
316
+
317
+
318
+ <li class="public ">
319
+ <span class="summary_signature">
320
+
321
+ <a href="#destroy_all-instance_method" title="#destroy_all (instance method)">- (Object) <strong>destroy_all</strong> </a>
322
+
323
+
324
+
325
+ </span>
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+ <span class="summary_desc"><div class='inline'><p>Destroys all members of the association and removes them from the association.</p>
335
+ </div></span>
336
+
337
+ </li>
338
+
339
+
340
+ <li class="public ">
341
+ <span class="summary_signature">
342
+
343
+ <a href="#each-instance_method" title="#each (instance method)">- (Dynamoid::Document) <strong>each</strong>(&amp;block) </a>
344
+
345
+
346
+
347
+ </span>
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+ <span class="summary_desc"><div class='inline'><p>Create a new instance of the target class and add it directly to the association.</p>
357
+ </div></span>
358
+
359
+ </li>
360
+
361
+
362
+ <li class="public ">
363
+ <span class="summary_signature">
364
+
365
+ <a href="#include%3F-instance_method" title="#include? (instance method)">- (Boolean) <strong>include?</strong>(object) </a>
366
+
367
+
368
+
369
+ </span>
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+ <span class="summary_desc"><div class='inline'><p>Delegate include? to the records.</p>
379
+ </div></span>
380
+
381
+ </li>
382
+
383
+
384
+ <li class="public ">
385
+ <span class="summary_signature">
386
+
387
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Dynamoid::Association) <strong>initialize</strong>(source, name, options) </a>
388
+
389
+
390
+
391
+ </span>
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+ <span class="summary_desc"><div class='inline'><p>Create a new association.</p>
401
+ </div></span>
402
+
403
+ </li>
404
+
405
+
406
+ <li class="public ">
407
+ <span class="summary_signature">
408
+
409
+ <a href="#records-instance_method" title="#records (instance method)">- (Object) <strong>records</strong> </a>
410
+
411
+
412
+
413
+ (also: #all)
414
+
415
+ </span>
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+ <span class="summary_desc"><div class='inline'><p>The records associated to the source.</p>
425
+ </div></span>
426
+
427
+ </li>
428
+
429
+
430
+ <li class="public ">
431
+ <span class="summary_signature">
432
+
433
+ <a href="#setter-instance_method" title="#setter (instance method)">- (Dynamoid::Document) <strong>setter</strong>(object) </a>
434
+
435
+
436
+
437
+ </span>
438
+
439
+
440
+
441
+
442
+
443
+
444
+
445
+
446
+ <span class="summary_desc"><div class='inline'><p>Replace an association with object or array of objects.</p>
447
+ </div></span>
448
+
449
+ </li>
450
+
451
+
452
+ <li class="public ">
453
+ <span class="summary_signature">
454
+
455
+ <a href="#where-instance_method" title="#where (instance method)">- (Dynamoid::Association) <strong>where</strong>(args) </a>
456
+
457
+
458
+
459
+ </span>
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+ <span class="summary_desc"><div class='inline'><p>Naive association filtering.</p>
469
+ </div></span>
470
+
471
+ </li>
472
+
473
+
474
+ </ul>
475
+
476
+
477
+
478
+
479
+ <div id="instance_attr_details" class="attr_details">
480
+ <h2>Instance Attribute Details</h2>
481
+
482
+
483
+ <span id="name=-instance_method"></span>
484
+ <span id="name-instance_method"></span>
485
+ <div class="method_details first">
486
+ <p class="signature first" id="name-instance_method">
487
+
488
+ - (<tt>Object</tt>) <strong>name</strong>
489
+
490
+
491
+
492
+ </p><div class="docstring">
493
+ <div class="discussion">
494
+ <p>Returns the value of attribute name</p>
495
+
496
+
497
+ </div>
498
+ </div>
499
+ <div class="tags">
500
+
501
+
502
+ </div><table class="source_code">
503
+ <tr>
504
+ <td>
505
+ <pre class="lines">
506
+
507
+
508
+ 9
509
+ 10
510
+ 11</pre>
511
+ </td>
512
+ <td>
513
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 9</span>
514
+
515
+ <span class='kw'>def</span> <span class='id identifier rubyid_name'>name</span>
516
+ <span class='ivar'>@name</span>
517
+ <span class='kw'>end</span></pre>
518
+ </td>
519
+ </tr>
520
+ </table>
521
+ </div>
522
+
523
+
524
+ <span id="options=-instance_method"></span>
525
+ <span id="options-instance_method"></span>
526
+ <div class="method_details ">
527
+ <p class="signature " id="options-instance_method">
528
+
529
+ - (<tt>Object</tt>) <strong>options</strong>
530
+
531
+
532
+
533
+ </p><div class="docstring">
534
+ <div class="discussion">
535
+ <p>Returns the value of attribute options</p>
536
+
537
+
538
+ </div>
539
+ </div>
540
+ <div class="tags">
541
+
542
+
543
+ </div><table class="source_code">
544
+ <tr>
545
+ <td>
546
+ <pre class="lines">
547
+
548
+
549
+ 9
550
+ 10
551
+ 11</pre>
552
+ </td>
553
+ <td>
554
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 9</span>
555
+
556
+ <span class='kw'>def</span> <span class='id identifier rubyid_options'>options</span>
557
+ <span class='ivar'>@options</span>
558
+ <span class='kw'>end</span></pre>
559
+ </td>
560
+ </tr>
561
+ </table>
562
+ </div>
563
+
564
+
565
+ <span id="query=-instance_method"></span>
566
+ <span id="query-instance_method"></span>
567
+ <div class="method_details ">
568
+ <p class="signature " id="query-instance_method">
569
+
570
+ - (<tt>Object</tt>) <strong>query</strong>
571
+
572
+
573
+
574
+ </p><div class="docstring">
575
+ <div class="discussion">
576
+ <p>Returns the value of attribute query</p>
577
+
578
+
579
+ </div>
580
+ </div>
581
+ <div class="tags">
582
+
583
+
584
+ </div><table class="source_code">
585
+ <tr>
586
+ <td>
587
+ <pre class="lines">
588
+
589
+
590
+ 9
591
+ 10
592
+ 11</pre>
593
+ </td>
594
+ <td>
595
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 9</span>
596
+
597
+ <span class='kw'>def</span> <span class='id identifier rubyid_query'>query</span>
598
+ <span class='ivar'>@query</span>
599
+ <span class='kw'>end</span></pre>
600
+ </td>
601
+ </tr>
602
+ </table>
603
+ </div>
604
+
605
+
606
+ <span id="source=-instance_method"></span>
607
+ <span id="source-instance_method"></span>
608
+ <div class="method_details ">
609
+ <p class="signature " id="source-instance_method">
610
+
611
+ - (<tt>Object</tt>) <strong>source</strong>
612
+
613
+
614
+
615
+ </p><div class="docstring">
616
+ <div class="discussion">
617
+ <p>Returns the value of attribute source</p>
618
+
619
+
620
+ </div>
621
+ </div>
622
+ <div class="tags">
623
+
624
+
625
+ </div><table class="source_code">
626
+ <tr>
627
+ <td>
628
+ <pre class="lines">
629
+
630
+
631
+ 9
632
+ 10
633
+ 11</pre>
634
+ </td>
635
+ <td>
636
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 9</span>
637
+
638
+ <span class='kw'>def</span> <span class='id identifier rubyid_source'>source</span>
639
+ <span class='ivar'>@source</span>
640
+ <span class='kw'>end</span></pre>
641
+ </td>
642
+ </tr>
643
+ </table>
644
+ </div>
645
+
646
+ </div>
647
+
648
+
649
+ <div id="instance_method_details" class="method_details_list">
650
+ <h2>Instance Method Details</h2>
651
+
652
+
653
+ <div class="method_details first">
654
+ <p class="signature first" id="<<-instance_method">
655
+
656
+ - (<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>) <strong>&lt;&lt;</strong>(object)
657
+
658
+
659
+
660
+ </p><div class="docstring">
661
+ <div class="discussion">
662
+ <p>Add an object or array of objects to an association. This preserves the current records in the association (if any)
663
+ and adds the object to the target association if it is detected to exist.</p>
664
+
665
+
666
+ </div>
667
+ </div>
668
+ <div class="tags">
669
+ <h3>Parameters:</h3>
670
+ <ul class="param">
671
+
672
+ <li>
673
+
674
+ <span class='name'>object</span>
675
+
676
+
677
+ <span class='type'>(<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>)</span>
678
+
679
+
680
+
681
+ &mdash;
682
+ <div class='inline'><p>the object (or array of objects) to add to the association</p>
683
+ </div>
684
+
685
+ </li>
686
+
687
+ </ul>
688
+
689
+ <h3>Returns:</h3>
690
+ <ul class="return">
691
+
692
+ <li>
693
+
694
+
695
+ <span class='type'>(<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>)</span>
696
+
697
+
698
+
699
+ &mdash;
700
+ <div class='inline'><p>the added object</p>
701
+ </div>
702
+
703
+ </li>
704
+
705
+ </ul>
706
+ <h3>Since:</h3>
707
+ <ul class="since">
708
+
709
+ <li>
710
+
711
+
712
+
713
+
714
+
715
+ <div class='inline'><p>0.2.0</p>
716
+ </div>
717
+
718
+ </li>
719
+
720
+ </ul>
721
+
722
+ </div><table class="source_code">
723
+ <tr>
724
+ <td>
725
+ <pre class="lines">
726
+
727
+
728
+ 83
729
+ 84
730
+ 85
731
+ 86
732
+ 87</pre>
733
+ </td>
734
+ <td>
735
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 83</span>
736
+
737
+ <span class='kw'>def</span> <span class='op'>&lt;&lt;</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
738
+ <span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_update_attribute'>update_attribute</span><span class='lparen'>(</span><span class='id identifier rubyid_source_attribute'>source_attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_source_ids'>source_ids</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:id</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rparen'>)</span>
739
+ <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_o'>o</span><span class='op'>|</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='symbol'>:associate_target</span><span class='comma'>,</span> <span class='id identifier rubyid_o'>o</span><span class='rparen'>)</span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_target_association'>target_association</span>
740
+ <span class='id identifier rubyid_object'>object</span>
741
+ <span class='kw'>end</span></pre>
742
+ </td>
743
+ </tr>
744
+ </table>
745
+ </div>
746
+
747
+ <div class="method_details ">
748
+ <p class="signature " id="create-instance_method">
749
+
750
+ - (<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>) <strong>create</strong>(attributes = {})
751
+
752
+
753
+
754
+ </p><div class="docstring">
755
+ <div class="discussion">
756
+ <p>Create a new instance of the target class and add it directly to the association.</p>
757
+
758
+
759
+ </div>
760
+ </div>
761
+ <div class="tags">
762
+ <h3>Parameters:</h3>
763
+ <ul class="param">
764
+
765
+ <li>
766
+
767
+ <span class='name'>attribute</span>
768
+
769
+
770
+ <span class='type'>(<tt>Hash</tt>)</span>
771
+
772
+
773
+
774
+ &mdash;
775
+ <div class='inline'><p>hash for the new object</p>
776
+ </div>
777
+
778
+ </li>
779
+
780
+ </ul>
781
+
782
+ <h3>Returns:</h3>
783
+ <ul class="return">
784
+
785
+ <li>
786
+
787
+
788
+ <span class='type'>(<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>)</span>
789
+
790
+
791
+
792
+ &mdash;
793
+ <div class='inline'><p>the newly-created object</p>
794
+ </div>
795
+
796
+ </li>
797
+
798
+ </ul>
799
+ <h3>Since:</h3>
800
+ <ul class="since">
801
+
802
+ <li>
803
+
804
+
805
+
806
+
807
+
808
+ <div class='inline'><p>0.2.0</p>
809
+ </div>
810
+
811
+ </li>
812
+
813
+ </ul>
814
+
815
+ </div><table class="source_code">
816
+ <tr>
817
+ <td>
818
+ <pre class="lines">
819
+
820
+
821
+ 110
822
+ 111
823
+ 112</pre>
824
+ </td>
825
+ <td>
826
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 110</span>
827
+
828
+ <span class='kw'>def</span> <span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_attributes'>attributes</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
829
+ <span class='kw'>self</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_target_class'>target_class</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_attributes'>attributes</span><span class='rparen'>)</span>
830
+ <span class='kw'>end</span></pre>
831
+ </td>
832
+ </tr>
833
+ </table>
834
+ </div>
835
+
836
+ <div class="method_details ">
837
+ <p class="signature " id="create!-instance_method">
838
+
839
+ - (<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>) <strong>create!</strong>(attributes = {})
840
+
841
+
842
+
843
+ </p><div class="docstring">
844
+ <div class="discussion">
845
+ <p>Create a new instance of the target class and add it directly to the association. If the create fails an exception will be raised.</p>
846
+
847
+
848
+ </div>
849
+ </div>
850
+ <div class="tags">
851
+ <h3>Parameters:</h3>
852
+ <ul class="param">
853
+
854
+ <li>
855
+
856
+ <span class='name'>attribute</span>
857
+
858
+
859
+ <span class='type'>(<tt>Hash</tt>)</span>
860
+
861
+
862
+
863
+ &mdash;
864
+ <div class='inline'><p>hash for the new object</p>
865
+ </div>
866
+
867
+ </li>
868
+
869
+ </ul>
870
+
871
+ <h3>Returns:</h3>
872
+ <ul class="return">
873
+
874
+ <li>
875
+
876
+
877
+ <span class='type'>(<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>)</span>
878
+
879
+
880
+
881
+ &mdash;
882
+ <div class='inline'><p>the newly-created object</p>
883
+ </div>
884
+
885
+ </li>
886
+
887
+ </ul>
888
+ <h3>Since:</h3>
889
+ <ul class="since">
890
+
891
+ <li>
892
+
893
+
894
+
895
+
896
+
897
+ <div class='inline'><p>0.2.0</p>
898
+ </div>
899
+
900
+ </li>
901
+
902
+ </ul>
903
+
904
+ </div><table class="source_code">
905
+ <tr>
906
+ <td>
907
+ <pre class="lines">
908
+
909
+
910
+ 121
911
+ 122
912
+ 123</pre>
913
+ </td>
914
+ <td>
915
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 121</span>
916
+
917
+ <span class='kw'>def</span> <span class='id identifier rubyid_create!'>create!</span><span class='lparen'>(</span><span class='id identifier rubyid_attributes'>attributes</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
918
+ <span class='kw'>self</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_target_class'>target_class</span><span class='period'>.</span><span class='id identifier rubyid_create!'>create!</span><span class='lparen'>(</span><span class='id identifier rubyid_attributes'>attributes</span><span class='rparen'>)</span>
919
+ <span class='kw'>end</span></pre>
920
+ </td>
921
+ </tr>
922
+ </table>
923
+ </div>
924
+
925
+ <div class="method_details ">
926
+ <p class="signature " id="delete-instance_method">
927
+
928
+ - (<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>) <strong>delete</strong>(object)
929
+
930
+
931
+
932
+ </p><div class="docstring">
933
+ <div class="discussion">
934
+ <p>Deletes an object or array of objects from the association. This removes their records from the association field on the source,
935
+ and attempts to remove the source from the target association if it is detected to exist.</p>
936
+
937
+
938
+ </div>
939
+ </div>
940
+ <div class="tags">
941
+ <h3>Parameters:</h3>
942
+ <ul class="param">
943
+
944
+ <li>
945
+
946
+ <span class='name'>object</span>
947
+
948
+
949
+ <span class='type'>(<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>)</span>
950
+
951
+
952
+
953
+ &mdash;
954
+ <div class='inline'><p>the object (or array of objects) to remove from the association</p>
955
+ </div>
956
+
957
+ </li>
958
+
959
+ </ul>
960
+
961
+ <h3>Returns:</h3>
962
+ <ul class="return">
963
+
964
+ <li>
965
+
966
+
967
+ <span class='type'>(<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>)</span>
968
+
969
+
970
+
971
+ &mdash;
972
+ <div class='inline'><p>the deleted object</p>
973
+ </div>
974
+
975
+ </li>
976
+
977
+ </ul>
978
+ <h3>Since:</h3>
979
+ <ul class="since">
980
+
981
+ <li>
982
+
983
+
984
+
985
+
986
+
987
+ <div class='inline'><p>0.2.0</p>
988
+ </div>
989
+
990
+ </li>
991
+
992
+ </ul>
993
+
994
+ </div><table class="source_code">
995
+ <tr>
996
+ <td>
997
+ <pre class="lines">
998
+
999
+
1000
+ 69
1001
+ 70
1002
+ 71
1003
+ 72
1004
+ 73</pre>
1005
+ </td>
1006
+ <td>
1007
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 69</span>
1008
+
1009
+ <span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
1010
+ <span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_update_attribute'>update_attribute</span><span class='lparen'>(</span><span class='id identifier rubyid_source_attribute'>source_attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_source_ids'>source_ids</span> <span class='op'>-</span> <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:id</span><span class='rparen'>)</span><span class='rparen'>)</span>
1011
+ <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_o'>o</span><span class='op'>|</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='symbol'>:disassociate_target</span><span class='comma'>,</span> <span class='id identifier rubyid_o'>o</span><span class='rparen'>)</span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_target_association'>target_association</span>
1012
+ <span class='id identifier rubyid_object'>object</span>
1013
+ <span class='kw'>end</span></pre>
1014
+ </td>
1015
+ </tr>
1016
+ </table>
1017
+ </div>
1018
+
1019
+ <div class="method_details ">
1020
+ <p class="signature " id="delete_all-instance_method">
1021
+
1022
+ - (<tt>Object</tt>) <strong>delete_all</strong>
1023
+
1024
+
1025
+
1026
+ </p><div class="docstring">
1027
+ <div class="discussion">
1028
+ <p>Deletes all members of the association and removes them from the association.</p>
1029
+
1030
+
1031
+ </div>
1032
+ </div>
1033
+ <div class="tags">
1034
+
1035
+ <h3>Since:</h3>
1036
+ <ul class="since">
1037
+
1038
+ <li>
1039
+
1040
+
1041
+
1042
+
1043
+
1044
+ <div class='inline'><p>0.2.0</p>
1045
+ </div>
1046
+
1047
+ </li>
1048
+
1049
+ </ul>
1050
+
1051
+ </div><table class="source_code">
1052
+ <tr>
1053
+ <td>
1054
+ <pre class="lines">
1055
+
1056
+
1057
+ 161
1058
+ 162
1059
+ 163
1060
+ 164
1061
+ 165</pre>
1062
+ </td>
1063
+ <td>
1064
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 161</span>
1065
+
1066
+ <span class='kw'>def</span> <span class='id identifier rubyid_delete_all'>delete_all</span>
1067
+ <span class='id identifier rubyid_objs'>objs</span> <span class='op'>=</span> <span class='id identifier rubyid_records'>records</span>
1068
+ <span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_update_attribute'>update_attribute</span><span class='lparen'>(</span><span class='id identifier rubyid_source_attribute'>source_attribute</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rparen'>)</span>
1069
+ <span class='id identifier rubyid_objs'>objs</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:delete</span><span class='rparen'>)</span>
1070
+ <span class='kw'>end</span></pre>
1071
+ </td>
1072
+ </tr>
1073
+ </table>
1074
+ </div>
1075
+
1076
+ <div class="method_details ">
1077
+ <p class="signature " id="destroy_all-instance_method">
1078
+
1079
+ - (<tt>Object</tt>) <strong>destroy_all</strong>
1080
+
1081
+
1082
+
1083
+ </p><div class="docstring">
1084
+ <div class="discussion">
1085
+ <p>Destroys all members of the association and removes them from the association.</p>
1086
+
1087
+
1088
+ </div>
1089
+ </div>
1090
+ <div class="tags">
1091
+
1092
+ <h3>Since:</h3>
1093
+ <ul class="since">
1094
+
1095
+ <li>
1096
+
1097
+
1098
+
1099
+
1100
+
1101
+ <div class='inline'><p>0.2.0</p>
1102
+ </div>
1103
+
1104
+ </li>
1105
+
1106
+ </ul>
1107
+
1108
+ </div><table class="source_code">
1109
+ <tr>
1110
+ <td>
1111
+ <pre class="lines">
1112
+
1113
+
1114
+ 152
1115
+ 153
1116
+ 154
1117
+ 155
1118
+ 156</pre>
1119
+ </td>
1120
+ <td>
1121
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 152</span>
1122
+
1123
+ <span class='kw'>def</span> <span class='id identifier rubyid_destroy_all'>destroy_all</span>
1124
+ <span class='id identifier rubyid_objs'>objs</span> <span class='op'>=</span> <span class='id identifier rubyid_records'>records</span>
1125
+ <span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_update_attribute'>update_attribute</span><span class='lparen'>(</span><span class='id identifier rubyid_source_attribute'>source_attribute</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rparen'>)</span>
1126
+ <span class='id identifier rubyid_objs'>objs</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:destroy</span><span class='rparen'>)</span>
1127
+ <span class='kw'>end</span></pre>
1128
+ </td>
1129
+ </tr>
1130
+ </table>
1131
+ </div>
1132
+
1133
+ <div class="method_details ">
1134
+ <p class="signature " id="each-instance_method">
1135
+
1136
+ - (<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>) <strong>each</strong>(&amp;block)
1137
+
1138
+
1139
+
1140
+ </p><div class="docstring">
1141
+ <div class="discussion">
1142
+ <p>Create a new instance of the target class and add it directly to the association. If the create fails an exception will be raised.</p>
1143
+
1144
+
1145
+ </div>
1146
+ </div>
1147
+ <div class="tags">
1148
+ <h3>Parameters:</h3>
1149
+ <ul class="param">
1150
+
1151
+ <li>
1152
+
1153
+ <span class='name'>attribute</span>
1154
+
1155
+
1156
+ <span class='type'>(<tt>Hash</tt>)</span>
1157
+
1158
+
1159
+
1160
+ &mdash;
1161
+ <div class='inline'><p>hash for the new object</p>
1162
+ </div>
1163
+
1164
+ </li>
1165
+
1166
+ </ul>
1167
+
1168
+ <h3>Returns:</h3>
1169
+ <ul class="return">
1170
+
1171
+ <li>
1172
+
1173
+
1174
+ <span class='type'>(<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>)</span>
1175
+
1176
+
1177
+
1178
+ &mdash;
1179
+ <div class='inline'><p>the newly-created object</p>
1180
+ </div>
1181
+
1182
+ </li>
1183
+
1184
+ </ul>
1185
+ <h3>Since:</h3>
1186
+ <ul class="since">
1187
+
1188
+ <li>
1189
+
1190
+
1191
+
1192
+
1193
+
1194
+ <div class='inline'><p>0.2.0</p>
1195
+ </div>
1196
+
1197
+ </li>
1198
+
1199
+ </ul>
1200
+
1201
+ </div><table class="source_code">
1202
+ <tr>
1203
+ <td>
1204
+ <pre class="lines">
1205
+
1206
+
1207
+ 145
1208
+ 146
1209
+ 147</pre>
1210
+ </td>
1211
+ <td>
1212
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 145</span>
1213
+
1214
+ <span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1215
+ <span class='id identifier rubyid_records'>records</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1216
+ <span class='kw'>end</span></pre>
1217
+ </td>
1218
+ </tr>
1219
+ </table>
1220
+ </div>
1221
+
1222
+ <div class="method_details ">
1223
+ <p class="signature " id="include?-instance_method">
1224
+
1225
+ - (<tt>Boolean</tt>) <strong>include?</strong>(object)
1226
+
1227
+
1228
+
1229
+ </p><div class="docstring">
1230
+ <div class="discussion">
1231
+ <p>Delegate include? to the records.</p>
1232
+
1233
+
1234
+ </div>
1235
+ </div>
1236
+ <div class="tags">
1237
+
1238
+ <h3>Returns:</h3>
1239
+ <ul class="return">
1240
+
1241
+ <li>
1242
+
1243
+
1244
+ <span class='type'>(<tt>Boolean</tt>)</span>
1245
+
1246
+
1247
+
1248
+ </li>
1249
+
1250
+ </ul>
1251
+
1252
+ </div><table class="source_code">
1253
+ <tr>
1254
+ <td>
1255
+ <pre class="lines">
1256
+
1257
+
1258
+ 55
1259
+ 56
1260
+ 57</pre>
1261
+ </td>
1262
+ <td>
1263
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 55</span>
1264
+
1265
+ <span class='kw'>def</span> <span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
1266
+ <span class='id identifier rubyid_records'>records</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
1267
+ <span class='kw'>end</span></pre>
1268
+ </td>
1269
+ </tr>
1270
+ </table>
1271
+ </div>
1272
+
1273
+ <div class="method_details ">
1274
+ <p class="signature " id="initialize-instance_method">
1275
+
1276
+ - (<tt>Dynamoid::Association</tt>) <strong>initialize</strong>(source, name, options)
1277
+
1278
+
1279
+
1280
+ </p><div class="docstring">
1281
+ <div class="discussion">
1282
+ <p>Create a new association.</p>
1283
+
1284
+
1285
+ </div>
1286
+ </div>
1287
+ <div class="tags">
1288
+ <h3>Parameters:</h3>
1289
+ <ul class="param">
1290
+
1291
+ <li>
1292
+
1293
+ <span class='name'>source</span>
1294
+
1295
+
1296
+ <span class='type'>(<tt>Class</tt>)</span>
1297
+
1298
+
1299
+
1300
+ &mdash;
1301
+ <div class='inline'><p>the source record of the association; that is, the record that you already have</p>
1302
+ </div>
1303
+
1304
+ </li>
1305
+
1306
+ <li>
1307
+
1308
+ <span class='name'>name</span>
1309
+
1310
+
1311
+ <span class='type'>(<tt>Symbol</tt>)</span>
1312
+
1313
+
1314
+
1315
+ &mdash;
1316
+ <div class='inline'><p>the name of the association</p>
1317
+ </div>
1318
+
1319
+ </li>
1320
+
1321
+ <li>
1322
+
1323
+ <span class='name'>options</span>
1324
+
1325
+
1326
+ <span class='type'>(<tt>Hash</tt>)</span>
1327
+
1328
+
1329
+
1330
+ &mdash;
1331
+ <div class='inline'><p>optional parameters for the association</p>
1332
+ </div>
1333
+
1334
+ </li>
1335
+
1336
+ </ul>
1337
+
1338
+
1339
+
1340
+
1341
+
1342
+
1343
+
1344
+
1345
+ <h3>Options Hash (<tt>options</tt>):</h3>
1346
+ <ul class="option">
1347
+
1348
+ <li>
1349
+ <span class="name">:class</span>
1350
+ <span class="type">(<tt>Class</tt>)</span>
1351
+ <span class="default">
1352
+
1353
+ </span>
1354
+ &mdash; <div class='inline'><p>the target class of the association; that is, the class to which the association objects belong</p>
1355
+ </div>
1356
+ </li>
1357
+
1358
+ <li>
1359
+ <span class="name">:class_name</span>
1360
+ <span class="type">(<tt>Symbol</tt>)</span>
1361
+ <span class="default">
1362
+
1363
+ </span>
1364
+ &mdash; <div class='inline'><p>the name of the target class of the association; only this or Class is necessary</p>
1365
+ </div>
1366
+ </li>
1367
+
1368
+ <li>
1369
+ <span class="name">:inverse_of</span>
1370
+ <span class="type">(<tt>Symbol</tt>)</span>
1371
+ <span class="default">
1372
+
1373
+ </span>
1374
+ &mdash; <div class='inline'><p>the name of the association on the target class</p>
1375
+ </div>
1376
+ </li>
1377
+
1378
+ </ul>
1379
+
1380
+
1381
+ <h3>Since:</h3>
1382
+ <ul class="since">
1383
+
1384
+ <li>
1385
+
1386
+
1387
+
1388
+
1389
+
1390
+ <div class='inline'><p>0.2.0</p>
1391
+ </div>
1392
+
1393
+ </li>
1394
+
1395
+ </ul>
1396
+
1397
+ </div><table class="source_code">
1398
+ <tr>
1399
+ <td>
1400
+ <pre class="lines">
1401
+
1402
+
1403
+ 27
1404
+ 28
1405
+ 29
1406
+ 30
1407
+ 31
1408
+ 32</pre>
1409
+ </td>
1410
+ <td>
1411
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 27</span>
1412
+
1413
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_source'>source</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
1414
+ <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span>
1415
+ <span class='ivar'>@options</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span>
1416
+ <span class='ivar'>@source</span> <span class='op'>=</span> <span class='id identifier rubyid_source'>source</span>
1417
+ <span class='ivar'>@query</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
1418
+ <span class='kw'>end</span></pre>
1419
+ </td>
1420
+ </tr>
1421
+ </table>
1422
+ </div>
1423
+
1424
+ <div class="method_details ">
1425
+ <p class="signature " id="records-instance_method">
1426
+
1427
+ - (<tt>Object</tt>) <strong>records</strong>
1428
+
1429
+
1430
+
1431
+ <span class="aliases">Also known as:
1432
+ <span class="names"><span id='all-instance_method'>all</span></span>
1433
+ </span>
1434
+
1435
+ </p><div class="docstring">
1436
+ <div class="discussion">
1437
+ <p>The records associated to the source.</p>
1438
+
1439
+
1440
+ </div>
1441
+ </div>
1442
+ <div class="tags">
1443
+
1444
+ <h3>Returns:</h3>
1445
+ <ul class="return">
1446
+
1447
+ <li>
1448
+
1449
+
1450
+ <span class='type'></span>
1451
+
1452
+
1453
+
1454
+
1455
+ <div class='inline'><p>the association records; depending on which association this is, either a single instance or an array</p>
1456
+ </div>
1457
+
1458
+ </li>
1459
+
1460
+ </ul>
1461
+ <h3>Since:</h3>
1462
+ <ul class="since">
1463
+
1464
+ <li>
1465
+
1466
+
1467
+
1468
+
1469
+
1470
+ <div class='inline'><p>0.2.0</p>
1471
+ </div>
1472
+
1473
+ </li>
1474
+
1475
+ </ul>
1476
+
1477
+ </div><table class="source_code">
1478
+ <tr>
1479
+ <td>
1480
+ <pre class="lines">
1481
+
1482
+
1483
+ 43
1484
+ 44
1485
+ 45
1486
+ 46
1487
+ 47
1488
+ 48
1489
+ 49
1490
+ 50
1491
+ 51</pre>
1492
+ </td>
1493
+ <td>
1494
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 43</span>
1495
+
1496
+ <span class='kw'>def</span> <span class='id identifier rubyid_records'>records</span>
1497
+ <span class='id identifier rubyid_results'>results</span> <span class='op'>=</span> <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_target_class'>target_class</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_source_ids'>source_ids</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span><span class='rparen'>)</span><span class='rparen'>)</span>
1498
+
1499
+ <span class='kw'>if</span> <span class='id identifier rubyid_query'>query</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
1500
+ <span class='id identifier rubyid_results'>results</span>
1501
+ <span class='kw'>else</span>
1502
+ <span class='id identifier rubyid_results_with_query'>results_with_query</span><span class='lparen'>(</span><span class='id identifier rubyid_results'>results</span><span class='rparen'>)</span>
1503
+ <span class='kw'>end</span>
1504
+ <span class='kw'>end</span></pre>
1505
+ </td>
1506
+ </tr>
1507
+ </table>
1508
+ </div>
1509
+
1510
+ <div class="method_details ">
1511
+ <p class="signature " id="setter-instance_method">
1512
+
1513
+ - (<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>) <strong>setter</strong>(object)
1514
+
1515
+
1516
+
1517
+ </p><div class="docstring">
1518
+ <div class="discussion">
1519
+ <p>Replace an association with object or array of objects. This removes all of the existing associated records and replaces them with
1520
+ the passed object(s), and associates the target association if it is detected to exist.</p>
1521
+
1522
+
1523
+ </div>
1524
+ </div>
1525
+ <div class="tags">
1526
+ <h3>Parameters:</h3>
1527
+ <ul class="param">
1528
+
1529
+ <li>
1530
+
1531
+ <span class='name'>object</span>
1532
+
1533
+
1534
+ <span class='type'>(<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>)</span>
1535
+
1536
+
1537
+
1538
+ &mdash;
1539
+ <div class='inline'><p>the object (or array of objects) to add to the association</p>
1540
+ </div>
1541
+
1542
+ </li>
1543
+
1544
+ </ul>
1545
+
1546
+ <h3>Returns:</h3>
1547
+ <ul class="return">
1548
+
1549
+ <li>
1550
+
1551
+
1552
+ <span class='type'>(<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>)</span>
1553
+
1554
+
1555
+
1556
+ &mdash;
1557
+ <div class='inline'><p>the added object</p>
1558
+ </div>
1559
+
1560
+ </li>
1561
+
1562
+ </ul>
1563
+ <h3>Since:</h3>
1564
+ <ul class="since">
1565
+
1566
+ <li>
1567
+
1568
+
1569
+
1570
+
1571
+
1572
+ <div class='inline'><p>0.2.0</p>
1573
+ </div>
1574
+
1575
+ </li>
1576
+
1577
+ </ul>
1578
+
1579
+ </div><table class="source_code">
1580
+ <tr>
1581
+ <td>
1582
+ <pre class="lines">
1583
+
1584
+
1585
+ 97
1586
+ 98
1587
+ 99
1588
+ 100
1589
+ 101</pre>
1590
+ </td>
1591
+ <td>
1592
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 97</span>
1593
+
1594
+ <span class='kw'>def</span> <span class='id identifier rubyid_setter'>setter</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
1595
+ <span class='id identifier rubyid_records'>records</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_o'>o</span><span class='op'>|</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_o'>o</span><span class='rparen'>)</span><span class='rbrace'>}</span>
1596
+ <span class='kw'>self</span> <span class='op'>&lt;&lt;</span> <span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
1597
+ <span class='id identifier rubyid_object'>object</span>
1598
+ <span class='kw'>end</span></pre>
1599
+ </td>
1600
+ </tr>
1601
+ </table>
1602
+ </div>
1603
+
1604
+ <div class="method_details ">
1605
+ <p class="signature " id="where-instance_method">
1606
+
1607
+ - (<tt>Dynamoid::Association</tt>) <strong>where</strong>(args)
1608
+
1609
+
1610
+
1611
+ </p><div class="docstring">
1612
+ <div class="discussion">
1613
+ <p>Naive association filtering.</p>
1614
+
1615
+
1616
+ </div>
1617
+ </div>
1618
+ <div class="tags">
1619
+ <h3>Parameters:</h3>
1620
+ <ul class="param">
1621
+
1622
+ <li>
1623
+
1624
+ <span class='name'>A</span>
1625
+
1626
+
1627
+ <span class='type'>(<tt>Hash</tt>)</span>
1628
+
1629
+
1630
+
1631
+ &mdash;
1632
+ <div class='inline'><p>hash of attributes; each must match every returned object's attribute exactly.</p>
1633
+ </div>
1634
+
1635
+ </li>
1636
+
1637
+ </ul>
1638
+
1639
+ <h3>Returns:</h3>
1640
+ <ul class="return">
1641
+
1642
+ <li>
1643
+
1644
+
1645
+ <span class='type'>(<tt>Dynamoid::Association</tt>)</span>
1646
+
1647
+
1648
+
1649
+ &mdash;
1650
+ <div class='inline'><p>the association this method was called on (for chaining purposes)</p>
1651
+ </div>
1652
+
1653
+ </li>
1654
+
1655
+ </ul>
1656
+ <h3>Since:</h3>
1657
+ <ul class="since">
1658
+
1659
+ <li>
1660
+
1661
+
1662
+
1663
+
1664
+
1665
+ <div class='inline'><p>0.2.0</p>
1666
+ </div>
1667
+
1668
+ </li>
1669
+
1670
+ </ul>
1671
+
1672
+ </div><table class="source_code">
1673
+ <tr>
1674
+ <td>
1675
+ <pre class="lines">
1676
+
1677
+
1678
+ 133
1679
+ 134
1680
+ 135
1681
+ 136</pre>
1682
+ </td>
1683
+ <td>
1684
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/associations/association.rb', line 133</span>
1685
+
1686
+ <span class='kw'>def</span> <span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
1687
+ <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_query'>query</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_v'>v</span><span class='rbrace'>}</span>
1688
+ <span class='kw'>self</span>
1689
+ <span class='kw'>end</span></pre>
1690
+ </td>
1691
+ </tr>
1692
+ </table>
1693
+ </div>
1694
+
1695
+ </div>
1696
+
1697
+ </div>
1698
+
1699
+ <div id="footer">
1700
+ Generated on Tue Mar 27 17:53:07 2012 by
1701
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1702
+ 0.7.5 (ruby-1.9.3).
1703
+ </div>
1704
+
1705
+ </body>
1706
+ </html>