adept_dynamoid 0.5.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Dynamoid.gemspec +193 -0
  4. data/Gemfile +23 -0
  5. data/Gemfile.lock +86 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.markdown +265 -0
  8. data/Rakefile +62 -0
  9. data/VERSION +1 -0
  10. data/doc/.nojekyll +0 -0
  11. data/doc/Dynamoid.html +312 -0
  12. data/doc/Dynamoid/Adapter.html +1385 -0
  13. data/doc/Dynamoid/Adapter/AwsSdk.html +1585 -0
  14. data/doc/Dynamoid/Adapter/Local.html +1574 -0
  15. data/doc/Dynamoid/Associations.html +131 -0
  16. data/doc/Dynamoid/Associations/Association.html +794 -0
  17. data/doc/Dynamoid/Associations/BelongsTo.html +158 -0
  18. data/doc/Dynamoid/Associations/ClassMethods.html +723 -0
  19. data/doc/Dynamoid/Associations/HasAndBelongsToMany.html +164 -0
  20. data/doc/Dynamoid/Associations/HasMany.html +164 -0
  21. data/doc/Dynamoid/Associations/HasOne.html +158 -0
  22. data/doc/Dynamoid/Associations/ManyAssociation.html +1640 -0
  23. data/doc/Dynamoid/Associations/SingleAssociation.html +598 -0
  24. data/doc/Dynamoid/Components.html +204 -0
  25. data/doc/Dynamoid/Config.html +395 -0
  26. data/doc/Dynamoid/Config/Options.html +609 -0
  27. data/doc/Dynamoid/Criteria.html +131 -0
  28. data/doc/Dynamoid/Criteria/Chain.html +1063 -0
  29. data/doc/Dynamoid/Criteria/ClassMethods.html +98 -0
  30. data/doc/Dynamoid/Document.html +666 -0
  31. data/doc/Dynamoid/Document/ClassMethods.html +937 -0
  32. data/doc/Dynamoid/Errors.html +118 -0
  33. data/doc/Dynamoid/Errors/DocumentNotValid.html +210 -0
  34. data/doc/Dynamoid/Errors/Error.html +130 -0
  35. data/doc/Dynamoid/Errors/InvalidField.html +133 -0
  36. data/doc/Dynamoid/Errors/MissingRangeKey.html +133 -0
  37. data/doc/Dynamoid/Fields.html +669 -0
  38. data/doc/Dynamoid/Fields/ClassMethods.html +309 -0
  39. data/doc/Dynamoid/Finders.html +128 -0
  40. data/doc/Dynamoid/Finders/ClassMethods.html +516 -0
  41. data/doc/Dynamoid/Indexes.html +308 -0
  42. data/doc/Dynamoid/Indexes/ClassMethods.html +353 -0
  43. data/doc/Dynamoid/Indexes/Index.html +1104 -0
  44. data/doc/Dynamoid/Persistence.html +651 -0
  45. data/doc/Dynamoid/Persistence/ClassMethods.html +670 -0
  46. data/doc/Dynamoid/Validations.html +399 -0
  47. data/doc/_index.html +461 -0
  48. data/doc/class_list.html +47 -0
  49. data/doc/css/common.css +1 -0
  50. data/doc/css/full_list.css +55 -0
  51. data/doc/css/style.css +322 -0
  52. data/doc/file.LICENSE.html +66 -0
  53. data/doc/file.README.html +312 -0
  54. data/doc/file_list.html +52 -0
  55. data/doc/frames.html +13 -0
  56. data/doc/index.html +312 -0
  57. data/doc/js/app.js +205 -0
  58. data/doc/js/full_list.js +173 -0
  59. data/doc/js/jquery.js +16 -0
  60. data/doc/method_list.html +1238 -0
  61. data/doc/top-level-namespace.html +105 -0
  62. data/lib/dynamoid.rb +47 -0
  63. data/lib/dynamoid/adapter.rb +177 -0
  64. data/lib/dynamoid/adapter/aws_sdk.rb +223 -0
  65. data/lib/dynamoid/associations.rb +106 -0
  66. data/lib/dynamoid/associations/association.rb +105 -0
  67. data/lib/dynamoid/associations/belongs_to.rb +44 -0
  68. data/lib/dynamoid/associations/has_and_belongs_to_many.rb +40 -0
  69. data/lib/dynamoid/associations/has_many.rb +39 -0
  70. data/lib/dynamoid/associations/has_one.rb +39 -0
  71. data/lib/dynamoid/associations/many_association.rb +191 -0
  72. data/lib/dynamoid/associations/single_association.rb +69 -0
  73. data/lib/dynamoid/components.rb +36 -0
  74. data/lib/dynamoid/config.rb +57 -0
  75. data/lib/dynamoid/config/options.rb +78 -0
  76. data/lib/dynamoid/criteria.rb +29 -0
  77. data/lib/dynamoid/criteria/chain.rb +243 -0
  78. data/lib/dynamoid/dirty.rb +41 -0
  79. data/lib/dynamoid/document.rb +184 -0
  80. data/lib/dynamoid/errors.rb +28 -0
  81. data/lib/dynamoid/fields.rb +130 -0
  82. data/lib/dynamoid/finders.rb +131 -0
  83. data/lib/dynamoid/identity_map.rb +96 -0
  84. data/lib/dynamoid/indexes.rb +69 -0
  85. data/lib/dynamoid/indexes/index.rb +103 -0
  86. data/lib/dynamoid/middleware/identity_map.rb +16 -0
  87. data/lib/dynamoid/persistence.rb +247 -0
  88. data/lib/dynamoid/validations.rb +36 -0
  89. data/spec/app/models/address.rb +10 -0
  90. data/spec/app/models/camel_case.rb +24 -0
  91. data/spec/app/models/magazine.rb +11 -0
  92. data/spec/app/models/message.rb +9 -0
  93. data/spec/app/models/sponsor.rb +8 -0
  94. data/spec/app/models/subscription.rb +12 -0
  95. data/spec/app/models/tweet.rb +12 -0
  96. data/spec/app/models/user.rb +26 -0
  97. data/spec/dynamoid/adapter/aws_sdk_spec.rb +186 -0
  98. data/spec/dynamoid/adapter_spec.rb +117 -0
  99. data/spec/dynamoid/associations/association_spec.rb +194 -0
  100. data/spec/dynamoid/associations/belongs_to_spec.rb +71 -0
  101. data/spec/dynamoid/associations/has_and_belongs_to_many_spec.rb +47 -0
  102. data/spec/dynamoid/associations/has_many_spec.rb +42 -0
  103. data/spec/dynamoid/associations/has_one_spec.rb +45 -0
  104. data/spec/dynamoid/associations_spec.rb +16 -0
  105. data/spec/dynamoid/config_spec.rb +27 -0
  106. data/spec/dynamoid/criteria/chain_spec.rb +140 -0
  107. data/spec/dynamoid/criteria_spec.rb +72 -0
  108. data/spec/dynamoid/dirty_spec.rb +49 -0
  109. data/spec/dynamoid/document_spec.rb +118 -0
  110. data/spec/dynamoid/fields_spec.rb +127 -0
  111. data/spec/dynamoid/finders_spec.rb +135 -0
  112. data/spec/dynamoid/identity_map_spec.rb +45 -0
  113. data/spec/dynamoid/indexes/index_spec.rb +104 -0
  114. data/spec/dynamoid/indexes_spec.rb +25 -0
  115. data/spec/dynamoid/persistence_spec.rb +176 -0
  116. data/spec/dynamoid/validations_spec.rb +36 -0
  117. data/spec/dynamoid_spec.rb +9 -0
  118. data/spec/spec_helper.rb +50 -0
  119. metadata +376 -0
@@ -0,0 +1,1104 @@
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
+ Class: Dynamoid::Indexes::Index
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 (I)</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="../Indexes.html" title="Dynamoid::Indexes (module)">Indexes</a></span></span>
38
+ &raquo;
39
+ <span class="title">Index</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>Class: Dynamoid::Indexes::Index
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+ <dt class="r1">Inherits:</dt>
68
+ <dd class="r1">
69
+ <span class="inheritName">Object</span>
70
+
71
+ <ul class="fullTree">
72
+ <li>Object</li>
73
+
74
+ <li class="next">Dynamoid::Indexes::Index</li>
75
+
76
+ </ul>
77
+ <a href="#" class="inheritanceTree">show all</a>
78
+
79
+ </dd>
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+ <dt class="r2 last">Defined in:</dt>
90
+ <dd class="r2 last">lib/dynamoid/indexes/index.rb</dd>
91
+
92
+ </dl>
93
+ <div class="clear"></div>
94
+
95
+ <h2>Overview</h2><div class="docstring">
96
+ <div class="discussion">
97
+ <p>The class contains all the information an index contains, including its keys and which attributes it covers.</p>
98
+
99
+
100
+ </div>
101
+ </div>
102
+ <div class="tags">
103
+
104
+
105
+ </div>
106
+
107
+
108
+
109
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
110
+ <ul class="summary">
111
+
112
+ <li class="public ">
113
+ <span class="summary_signature">
114
+
115
+ <a href="#hash_keys-instance_method" title="#hash_keys (instance method)">- (Object) <strong>hash_keys</strong> </a>
116
+
117
+
118
+
119
+ </span>
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+ <span class="summary_desc"><div class='inline'><p>Returns the value of attribute hash_keys.</p>
132
+ </div></span>
133
+
134
+ </li>
135
+
136
+
137
+ <li class="public ">
138
+ <span class="summary_signature">
139
+
140
+ <a href="#name-instance_method" title="#name (instance method)">- (Object) <strong>name</strong> </a>
141
+
142
+
143
+
144
+ </span>
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+ <span class="summary_desc"><div class='inline'><p>Returns the value of attribute name.</p>
157
+ </div></span>
158
+
159
+ </li>
160
+
161
+
162
+ <li class="public ">
163
+ <span class="summary_signature">
164
+
165
+ <a href="#range_keys-instance_method" title="#range_keys (instance method)">- (Object) <strong>range_keys</strong> </a>
166
+
167
+
168
+
169
+ (also: #range_key?)
170
+
171
+ </span>
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+ <span class="summary_desc"><div class='inline'><p>Returns the value of attribute range_keys.</p>
184
+ </div></span>
185
+
186
+ </li>
187
+
188
+
189
+ <li class="public ">
190
+ <span class="summary_signature">
191
+
192
+ <a href="#source-instance_method" title="#source (instance method)">- (Object) <strong>source</strong> </a>
193
+
194
+
195
+
196
+ </span>
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+ <span class="summary_desc"><div class='inline'><p>Returns the value of attribute source.</p>
209
+ </div></span>
210
+
211
+ </li>
212
+
213
+
214
+ </ul>
215
+
216
+
217
+
218
+
219
+
220
+ <h2>
221
+ Instance Method Summary
222
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
223
+ </h2>
224
+
225
+ <ul class="summary">
226
+
227
+ <li class="public ">
228
+ <span class="summary_signature">
229
+
230
+ <a href="#delete-instance_method" title="#delete (instance method)">- (Object) <strong>delete</strong>(obj, changed_attributes = false) </a>
231
+
232
+
233
+
234
+ </span>
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+ <span class="summary_desc"><div class='inline'><p>Delete an object from this index, preserving existing ids if there are any, and failing gracefully if for some reason the
244
+ index doesn't already have this object in it.</p>
245
+ </div></span>
246
+
247
+ </li>
248
+
249
+
250
+ <li class="public ">
251
+ <span class="summary_signature">
252
+
253
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Index) <strong>initialize</strong>(source, name, options = {}) </a>
254
+
255
+
256
+
257
+ </span>
258
+
259
+ <span class="note title constructor">constructor</span>
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+ <span class="summary_desc"><div class='inline'><p>Create a new index.</p>
269
+ </div></span>
270
+
271
+ </li>
272
+
273
+
274
+ <li class="public ">
275
+ <span class="summary_signature">
276
+
277
+ <a href="#keys-instance_method" title="#keys (instance method)">- (Object) <strong>keys</strong> </a>
278
+
279
+
280
+
281
+ </span>
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+ <span class="summary_desc"><div class='inline'><p>Return the array of keys this index uses for its table.</p>
291
+ </div></span>
292
+
293
+ </li>
294
+
295
+
296
+ <li class="public ">
297
+ <span class="summary_signature">
298
+
299
+ <a href="#save-instance_method" title="#save (instance method)">- (Object) <strong>save</strong>(obj) </a>
300
+
301
+
302
+
303
+ </span>
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+ <span class="summary_desc"><div class='inline'><p>Save an object to this index, merging it with existing ids if there's already something present at this index location.</p>
313
+ </div></span>
314
+
315
+ </li>
316
+
317
+
318
+ <li class="public ">
319
+ <span class="summary_signature">
320
+
321
+ <a href="#sort-instance_method" title="#sort (instance method)">- (Object) <strong>sort</strong>(objs) </a>
322
+
323
+
324
+
325
+ </span>
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+ <span class="summary_desc"><div class='inline'><p>Sort objects into alphabetical strings, used for composing index names correctly (since we always assume they're alphabetical).</p>
335
+ </div></span>
336
+
337
+ </li>
338
+
339
+
340
+ <li class="public ">
341
+ <span class="summary_signature">
342
+
343
+ <a href="#table_name-instance_method" title="#table_name (instance method)">- (Object) <strong>table_name</strong> </a>
344
+
345
+
346
+
347
+ </span>
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+ <span class="summary_desc"><div class='inline'><p>Return the table name for this index.</p>
357
+ </div></span>
358
+
359
+ </li>
360
+
361
+
362
+ <li class="public ">
363
+ <span class="summary_signature">
364
+
365
+ <a href="#values-instance_method" title="#values (instance method)">- (Hash) <strong>values</strong>(attrs, changed_attributes = false) </a>
366
+
367
+
368
+
369
+ </span>
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+ <span class="summary_desc"><div class='inline'><p>Given either an object or a list of attributes, generate a hash key and a range key for the index.</p>
379
+ </div></span>
380
+
381
+ </li>
382
+
383
+
384
+ </ul>
385
+
386
+
387
+ <div id="constructor_details" class="method_details_list">
388
+ <h2>Constructor Details</h2>
389
+
390
+ <div class="method_details first">
391
+ <p class="signature first" id="initialize-instance_method">
392
+
393
+ - (<tt><span class='object_link'><a href="" title="Dynamoid::Indexes::Index (class)">Index</a></span></tt>) <strong>initialize</strong>(source, name, options = {})
394
+
395
+
396
+
397
+ </p><div class="docstring">
398
+ <div class="discussion">
399
+ <p>Create a new index. Pass either :range =&gt; true or :range =&gt; :column_name to create a ranged index on that column.</p>
400
+
401
+
402
+ </div>
403
+ </div>
404
+ <div class="tags">
405
+ <h3>Parameters:</h3>
406
+ <ul class="param">
407
+
408
+ <li>
409
+
410
+ <span class='name'>source</span>
411
+
412
+
413
+ <span class='type'>(<tt>Class</tt>)</span>
414
+
415
+
416
+
417
+ &mdash;
418
+ <div class='inline'><p>the source class for the index</p>
419
+ </div>
420
+
421
+ </li>
422
+
423
+ <li>
424
+
425
+ <span class='name'>name</span>
426
+
427
+
428
+ <span class='type'>(<tt>Symbol</tt>)</span>
429
+
430
+
431
+
432
+ &mdash;
433
+ <div class='inline'><p>the name of the index</p>
434
+ </div>
435
+
436
+ </li>
437
+
438
+ </ul>
439
+
440
+ <h3>Raises:</h3>
441
+ <ul class="raise">
442
+
443
+ <li>
444
+
445
+
446
+ <span class='type'>(<tt><span class='object_link'><a href="../Errors/InvalidField.html" title="Dynamoid::Errors::InvalidField (class)">Dynamoid::Errors::InvalidField</a></span></tt>)</span>
447
+
448
+
449
+
450
+ </li>
451
+
452
+ </ul>
453
+ <h3>Since:</h3>
454
+ <ul class="since">
455
+
456
+ <li>
457
+
458
+
459
+
460
+
461
+
462
+ <div class='inline'><p>0.2.0</p>
463
+ </div>
464
+
465
+ </li>
466
+
467
+ </ul>
468
+
469
+ </div><table class="source_code">
470
+ <tr>
471
+ <td>
472
+ <pre class="lines">
473
+
474
+
475
+ 16
476
+ 17
477
+ 18
478
+ 19
479
+ 20
480
+ 21
481
+ 22
482
+ 23
483
+ 24
484
+ 25
485
+ 26
486
+ 27
487
+ 28</pre>
488
+ </td>
489
+ <td>
490
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 16</span>
491
+
492
+ <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='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
493
+ <span class='ivar'>@source</span> <span class='op'>=</span> <span class='id identifier rubyid_source'>source</span>
494
+
495
+ <span class='kw'>if</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:range</span><span class='rparen'>)</span>
496
+ <span class='ivar'>@range_keys</span> <span class='op'>=</span> <span class='id identifier rubyid_sort'>sort</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
497
+ <span class='kw'>elsif</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:range_key</span><span class='rbracket'>]</span>
498
+ <span class='ivar'>@range_keys</span> <span class='op'>=</span> <span class='id identifier rubyid_sort'>sort</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:range_key</span><span class='rbracket'>]</span><span class='rparen'>)</span>
499
+ <span class='kw'>end</span>
500
+ <span class='ivar'>@hash_keys</span> <span class='op'>=</span> <span class='id identifier rubyid_sort'>sort</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
501
+ <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_sort'>sort</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='id identifier rubyid_hash_keys'>hash_keys</span><span class='comma'>,</span> <span class='id identifier rubyid_range_keys'>range_keys</span><span class='rbracket'>]</span><span class='rparen'>)</span>
502
+
503
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>InvalidField</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>A key specified for an index is not a field</span><span class='tstring_end'>'</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_all?'>all?</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_attributes'>attributes</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_n'>n</span><span class='rparen'>)</span><span class='rbrace'>}</span>
504
+ <span class='kw'>end</span></pre>
505
+ </td>
506
+ </tr>
507
+ </table>
508
+ </div>
509
+
510
+ </div>
511
+
512
+ <div id="instance_attr_details" class="attr_details">
513
+ <h2>Instance Attribute Details</h2>
514
+
515
+
516
+ <span id="hash_keys=-instance_method"></span>
517
+ <span id="hash_keys-instance_method"></span>
518
+ <div class="method_details first">
519
+ <p class="signature first" id="hash_keys-instance_method">
520
+
521
+ - (<tt>Object</tt>) <strong>hash_keys</strong>
522
+
523
+
524
+
525
+ </p><div class="docstring">
526
+ <div class="discussion">
527
+ <p>Returns the value of attribute hash_keys</p>
528
+
529
+
530
+ </div>
531
+ </div>
532
+ <div class="tags">
533
+
534
+
535
+ </div><table class="source_code">
536
+ <tr>
537
+ <td>
538
+ <pre class="lines">
539
+
540
+
541
+ 7
542
+ 8
543
+ 9</pre>
544
+ </td>
545
+ <td>
546
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 7</span>
547
+
548
+ <span class='kw'>def</span> <span class='id identifier rubyid_hash_keys'>hash_keys</span>
549
+ <span class='ivar'>@hash_keys</span>
550
+ <span class='kw'>end</span></pre>
551
+ </td>
552
+ </tr>
553
+ </table>
554
+ </div>
555
+
556
+
557
+ <span id="name=-instance_method"></span>
558
+ <span id="name-instance_method"></span>
559
+ <div class="method_details ">
560
+ <p class="signature " id="name-instance_method">
561
+
562
+ - (<tt>Object</tt>) <strong>name</strong>
563
+
564
+
565
+
566
+ </p><div class="docstring">
567
+ <div class="discussion">
568
+ <p>Returns the value of attribute name</p>
569
+
570
+
571
+ </div>
572
+ </div>
573
+ <div class="tags">
574
+
575
+
576
+ </div><table class="source_code">
577
+ <tr>
578
+ <td>
579
+ <pre class="lines">
580
+
581
+
582
+ 7
583
+ 8
584
+ 9</pre>
585
+ </td>
586
+ <td>
587
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 7</span>
588
+
589
+ <span class='kw'>def</span> <span class='id identifier rubyid_name'>name</span>
590
+ <span class='ivar'>@name</span>
591
+ <span class='kw'>end</span></pre>
592
+ </td>
593
+ </tr>
594
+ </table>
595
+ </div>
596
+
597
+
598
+ <span id="range_keys=-instance_method"></span>
599
+ <span id="range_keys-instance_method"></span>
600
+ <div class="method_details ">
601
+ <p class="signature " id="range_keys-instance_method">
602
+
603
+ - (<tt>Object</tt>) <strong>range_keys</strong>
604
+
605
+
606
+
607
+ <span class="aliases">Also known as:
608
+ <span class="names"><span id='range_key?-instance_method'>range_key?</span></span>
609
+ </span>
610
+
611
+ </p><div class="docstring">
612
+ <div class="discussion">
613
+ <p>Returns the value of attribute range_keys</p>
614
+
615
+
616
+ </div>
617
+ </div>
618
+ <div class="tags">
619
+
620
+
621
+ </div><table class="source_code">
622
+ <tr>
623
+ <td>
624
+ <pre class="lines">
625
+
626
+
627
+ 7
628
+ 8
629
+ 9</pre>
630
+ </td>
631
+ <td>
632
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 7</span>
633
+
634
+ <span class='kw'>def</span> <span class='id identifier rubyid_range_keys'>range_keys</span>
635
+ <span class='ivar'>@range_keys</span>
636
+ <span class='kw'>end</span></pre>
637
+ </td>
638
+ </tr>
639
+ </table>
640
+ </div>
641
+
642
+
643
+ <span id="source=-instance_method"></span>
644
+ <span id="source-instance_method"></span>
645
+ <div class="method_details ">
646
+ <p class="signature " id="source-instance_method">
647
+
648
+ - (<tt>Object</tt>) <strong>source</strong>
649
+
650
+
651
+
652
+ </p><div class="docstring">
653
+ <div class="discussion">
654
+ <p>Returns the value of attribute source</p>
655
+
656
+
657
+ </div>
658
+ </div>
659
+ <div class="tags">
660
+
661
+
662
+ </div><table class="source_code">
663
+ <tr>
664
+ <td>
665
+ <pre class="lines">
666
+
667
+
668
+ 7
669
+ 8
670
+ 9</pre>
671
+ </td>
672
+ <td>
673
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 7</span>
674
+
675
+ <span class='kw'>def</span> <span class='id identifier rubyid_source'>source</span>
676
+ <span class='ivar'>@source</span>
677
+ <span class='kw'>end</span></pre>
678
+ </td>
679
+ </tr>
680
+ </table>
681
+ </div>
682
+
683
+ </div>
684
+
685
+
686
+ <div id="instance_method_details" class="method_details_list">
687
+ <h2>Instance Method Details</h2>
688
+
689
+
690
+ <div class="method_details first">
691
+ <p class="signature first" id="delete-instance_method">
692
+
693
+ - (<tt>Object</tt>) <strong>delete</strong>(obj, changed_attributes = false)
694
+
695
+
696
+
697
+ </p><div class="docstring">
698
+ <div class="discussion">
699
+ <p>Delete an object from this index, preserving existing ids if there are any, and failing gracefully if for some reason the
700
+ index doesn't already have this object in it.</p>
701
+
702
+
703
+ </div>
704
+ </div>
705
+ <div class="tags">
706
+
707
+ <h3>Since:</h3>
708
+ <ul class="since">
709
+
710
+ <li>
711
+
712
+
713
+
714
+
715
+
716
+ <div class='inline'><p>0.2.0</p>
717
+ </div>
718
+
719
+ </li>
720
+
721
+ </ul>
722
+
723
+ </div><table class="source_code">
724
+ <tr>
725
+ <td>
726
+ <pre class="lines">
727
+
728
+
729
+ 93
730
+ 94
731
+ 95
732
+ 96
733
+ 97
734
+ 98
735
+ 99</pre>
736
+ </td>
737
+ <td>
738
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 93</span>
739
+
740
+ <span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='comma'>,</span> <span class='id identifier rubyid_changed_attributes'>changed_attributes</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
741
+ <span class='id identifier rubyid_values'>values</span> <span class='op'>=</span> <span class='id identifier rubyid_values'>values</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='comma'>,</span> <span class='id identifier rubyid_changed_attributes'>changed_attributes</span><span class='rparen'>)</span>
742
+ <span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
743
+ <span class='id identifier rubyid_existing'>existing</span> <span class='op'>=</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbrace'>{</span> <span class='symbol'>:range_key</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='rparen'>)</span>
744
+ <span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>unless</span> <span class='id identifier rubyid_existing'>existing</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_existing'>existing</span><span class='lbracket'>[</span><span class='symbol'>:ids</span><span class='rbracket'>]</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_existing'>existing</span><span class='lbracket'>[</span><span class='symbol'>:ids</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
745
+ <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:id</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='symbol'>:ids</span> <span class='op'>=&gt;</span> <span class='lparen'>(</span><span class='id identifier rubyid_existing'>existing</span><span class='lbracket'>[</span><span class='symbol'>:ids</span><span class='rbracket'>]</span> <span class='op'>-</span> <span class='const'>Set</span><span class='lbracket'>[</span><span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='symbol'>:range</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='rparen'>)</span>
746
+ <span class='kw'>end</span></pre>
747
+ </td>
748
+ </tr>
749
+ </table>
750
+ </div>
751
+
752
+ <div class="method_details ">
753
+ <p class="signature " id="keys-instance_method">
754
+
755
+ - (<tt>Object</tt>) <strong>keys</strong>
756
+
757
+
758
+
759
+ </p><div class="docstring">
760
+ <div class="discussion">
761
+ <p>Return the array of keys this index uses for its table.</p>
762
+
763
+
764
+ </div>
765
+ </div>
766
+ <div class="tags">
767
+
768
+ <h3>Since:</h3>
769
+ <ul class="since">
770
+
771
+ <li>
772
+
773
+
774
+
775
+
776
+
777
+ <div class='inline'><p>0.2.0</p>
778
+ </div>
779
+
780
+ </li>
781
+
782
+ </ul>
783
+
784
+ </div><table class="source_code">
785
+ <tr>
786
+ <td>
787
+ <pre class="lines">
788
+
789
+
790
+ 43
791
+ 44
792
+ 45</pre>
793
+ </td>
794
+ <td>
795
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 43</span>
796
+
797
+ <span class='kw'>def</span> <span class='id identifier rubyid_keys'>keys</span>
798
+ <span class='lbracket'>[</span><span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_hash_keys'>hash_keys</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_range_keys'>range_keys</span><span class='rparen'>)</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span>
799
+ <span class='kw'>end</span></pre>
800
+ </td>
801
+ </tr>
802
+ </table>
803
+ </div>
804
+
805
+ <div class="method_details ">
806
+ <p class="signature " id="save-instance_method">
807
+
808
+ - (<tt>Object</tt>) <strong>save</strong>(obj)
809
+
810
+
811
+
812
+ </p><div class="docstring">
813
+ <div class="discussion">
814
+ <p>Save an object to this index, merging it with existing ids if there's already something present at this index location.
815
+ First, though, delete this object from its old indexes (so the object isn't listed in an erroneous index).</p>
816
+
817
+
818
+ </div>
819
+ </div>
820
+ <div class="tags">
821
+
822
+ <h3>Since:</h3>
823
+ <ul class="since">
824
+
825
+ <li>
826
+
827
+
828
+
829
+
830
+
831
+ <div class='inline'><p>0.2.0</p>
832
+ </div>
833
+
834
+ </li>
835
+
836
+ </ul>
837
+
838
+ </div><table class="source_code">
839
+ <tr>
840
+ <td>
841
+ <pre class="lines">
842
+
843
+
844
+ 80
845
+ 81
846
+ 82
847
+ 83
848
+ 84
849
+ 85
850
+ 86
851
+ 87</pre>
852
+ </td>
853
+ <td>
854
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 80</span>
855
+
856
+ <span class='kw'>def</span> <span class='id identifier rubyid_save'>save</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='rparen'>)</span>
857
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span>
858
+ <span class='id identifier rubyid_values'>values</span> <span class='op'>=</span> <span class='id identifier rubyid_values'>values</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='rparen'>)</span>
859
+ <span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span>
860
+ <span class='id identifier rubyid_existing'>existing</span> <span class='op'>=</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbrace'>{</span> <span class='symbol'>:range_key</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
861
+ <span class='id identifier rubyid_ids'>ids</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_existing'>existing</span> <span class='kw'>and</span> <span class='id identifier rubyid_existing'>existing</span><span class='lbracket'>[</span><span class='symbol'>:ids</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>or</span> <span class='const'>Set</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
862
+ <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:id</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='symbol'>:ids</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_ids'>ids</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='symbol'>:range</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_values'>values</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='rparen'>)</span>
863
+ <span class='kw'>end</span></pre>
864
+ </td>
865
+ </tr>
866
+ </table>
867
+ </div>
868
+
869
+ <div class="method_details ">
870
+ <p class="signature " id="sort-instance_method">
871
+
872
+ - (<tt>Object</tt>) <strong>sort</strong>(objs)
873
+
874
+
875
+
876
+ </p><div class="docstring">
877
+ <div class="discussion">
878
+ <p>Sort objects into alphabetical strings, used for composing index names correctly (since we always assume they're alphabetical).</p>
879
+
880
+
881
+ </div>
882
+ </div>
883
+ <div class="tags">
884
+
885
+ <div class="examples">
886
+ <h3>Examples:</h3>
887
+
888
+ <h4><div class='inline'><p>find all users by first and last name</p>
889
+ </div></h4>
890
+ <pre class="example code"><span class='id identifier rubyid_sort'>sort</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='symbol'>:gamma</span><span class='comma'>,</span> <span class='symbol'>:alpha</span><span class='comma'>,</span> <span class='symbol'>:beta</span><span class='comma'>,</span> <span class='symbol'>:omega</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='comment'># =&gt; [:alpha, :beta, :gamma, :omega]</span></pre>
891
+
892
+ </div>
893
+
894
+ <h3>Since:</h3>
895
+ <ul class="since">
896
+
897
+ <li>
898
+
899
+
900
+
901
+
902
+
903
+ <div class='inline'><p>0.2.0</p>
904
+ </div>
905
+
906
+ </li>
907
+
908
+ </ul>
909
+
910
+ </div><table class="source_code">
911
+ <tr>
912
+ <td>
913
+ <pre class="lines">
914
+
915
+
916
+ 36
917
+ 37
918
+ 38</pre>
919
+ </td>
920
+ <td>
921
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 36</span>
922
+
923
+ <span class='kw'>def</span> <span class='id identifier rubyid_sort'>sort</span><span class='lparen'>(</span><span class='id identifier rubyid_objs'>objs</span><span class='rparen'>)</span>
924
+ <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_objs'>objs</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</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'>:to_s</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_sort'>sort</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'>:to_sym</span><span class='rparen'>)</span>
925
+ <span class='kw'>end</span></pre>
926
+ </td>
927
+ </tr>
928
+ </table>
929
+ </div>
930
+
931
+ <div class="method_details ">
932
+ <p class="signature " id="table_name-instance_method">
933
+
934
+ - (<tt>Object</tt>) <strong>table_name</strong>
935
+
936
+
937
+
938
+ </p><div class="docstring">
939
+ <div class="discussion">
940
+ <p>Return the table name for this index.</p>
941
+
942
+
943
+ </div>
944
+ </div>
945
+ <div class="tags">
946
+
947
+ <h3>Since:</h3>
948
+ <ul class="since">
949
+
950
+ <li>
951
+
952
+
953
+
954
+
955
+
956
+ <div class='inline'><p>0.2.0</p>
957
+ </div>
958
+
959
+ </li>
960
+
961
+ </ul>
962
+
963
+ </div><table class="source_code">
964
+ <tr>
965
+ <td>
966
+ <pre class="lines">
967
+
968
+
969
+ 50
970
+ 51
971
+ 52</pre>
972
+ </td>
973
+ <td>
974
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 50</span>
975
+
976
+ <span class='kw'>def</span> <span class='id identifier rubyid_table_name'>table_name</span>
977
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_namespace'>namespace</span><span class='rbrace'>}</span><span class='tstring_content'>_index_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_source'>source</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span><span class='rbrace'>}</span><span class='tstring_content'>_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</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'>:to_s</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'>:pluralize</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>_and_</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span>
978
+ <span class='kw'>end</span></pre>
979
+ </td>
980
+ </tr>
981
+ </table>
982
+ </div>
983
+
984
+ <div class="method_details ">
985
+ <p class="signature " id="values-instance_method">
986
+
987
+ - (<tt>Hash</tt>) <strong>values</strong>(attrs, changed_attributes = false)
988
+
989
+
990
+
991
+ </p><div class="docstring">
992
+ <div class="discussion">
993
+ <p>Given either an object or a list of attributes, generate a hash key and a range key for the index. Optionally pass in
994
+ true to changed_attributes for a list of all the object's dirty attributes in convenient index form (for deleting stale
995
+ information from the indexes).</p>
996
+
997
+
998
+ </div>
999
+ </div>
1000
+ <div class="tags">
1001
+ <h3>Parameters:</h3>
1002
+ <ul class="param">
1003
+
1004
+ <li>
1005
+
1006
+ <span class='name'>attrs</span>
1007
+
1008
+
1009
+ <span class='type'>(<tt>Object</tt>)</span>
1010
+
1011
+
1012
+
1013
+ &mdash;
1014
+ <div class='inline'><p>either an object that responds to :attributes, or a hash of attributes</p>
1015
+ </div>
1016
+
1017
+ </li>
1018
+
1019
+ </ul>
1020
+
1021
+ <h3>Returns:</h3>
1022
+ <ul class="return">
1023
+
1024
+ <li>
1025
+
1026
+
1027
+ <span class='type'>(<tt>Hash</tt>)</span>
1028
+
1029
+
1030
+
1031
+ &mdash;
1032
+ <div class='inline'><p>a hash with the keys :hash_value and :range_value</p>
1033
+ </div>
1034
+
1035
+ </li>
1036
+
1037
+ </ul>
1038
+ <h3>Since:</h3>
1039
+ <ul class="since">
1040
+
1041
+ <li>
1042
+
1043
+
1044
+
1045
+
1046
+
1047
+ <div class='inline'><p>0.2.0</p>
1048
+ </div>
1049
+
1050
+ </li>
1051
+
1052
+ </ul>
1053
+
1054
+ </div><table class="source_code">
1055
+ <tr>
1056
+ <td>
1057
+ <pre class="lines">
1058
+
1059
+
1060
+ 63
1061
+ 64
1062
+ 65
1063
+ 66
1064
+ 67
1065
+ 68
1066
+ 69
1067
+ 70
1068
+ 71
1069
+ 72
1070
+ 73
1071
+ 74</pre>
1072
+ </td>
1073
+ <td>
1074
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/indexes/index.rb', line 63</span>
1075
+
1076
+ <span class='kw'>def</span> <span class='id identifier rubyid_values'>values</span><span class='lparen'>(</span><span class='id identifier rubyid_attrs'>attrs</span><span class='comma'>,</span> <span class='id identifier rubyid_changed_attributes'>changed_attributes</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
1077
+ <span class='kw'>if</span> <span class='id identifier rubyid_changed_attributes'>changed_attributes</span>
1078
+ <span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
1079
+ <span class='id identifier rubyid_attrs'>attrs</span><span class='period'>.</span><span class='id identifier rubyid_changes'>changes</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_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='op'>||</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span><span class='rparen'>)</span><span class='rbrace'>}</span>
1080
+ <span class='id identifier rubyid_attrs'>attrs</span> <span class='op'>=</span> <span class='id identifier rubyid_hash'>hash</span>
1081
+ <span class='kw'>end</span>
1082
+ <span class='id identifier rubyid_attrs'>attrs</span> <span class='op'>=</span> <span class='id identifier rubyid_attrs'>attrs</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='symbol'>:attributes</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_attrs'>attrs</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:attributes</span><span class='rparen'>)</span>
1083
+ <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_tap'>tap</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_hash'>hash</span><span class='op'>|</span>
1084
+ <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_hash_keys'>hash_keys</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_key'>key</span><span class='op'>|</span> <span class='id identifier rubyid_attrs'>attrs</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
1085
+ <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_range_keys'>range_keys</span><span class='period'>.</span><span class='id identifier rubyid_inject'>inject</span><span class='lparen'>(</span><span class='float'>0.0</span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_sum'>sum</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='op'>|</span> <span class='id identifier rubyid_sum'>sum</span> <span class='op'>+</span> <span class='id identifier rubyid_attrs'>attrs</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_range_key?'>range_key?</span>
1086
+ <span class='kw'>end</span>
1087
+ <span class='kw'>end</span></pre>
1088
+ </td>
1089
+ </tr>
1090
+ </table>
1091
+ </div>
1092
+
1093
+ </div>
1094
+
1095
+ </div>
1096
+
1097
+ <div id="footer">
1098
+ Generated on Thu Apr 26 01:26:25 2012 by
1099
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1100
+ 0.7.5 (ruby-1.9.3).
1101
+ </div>
1102
+
1103
+ </body>
1104
+ </html>