adept_dynamoid 0.5.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Dynamoid.gemspec +193 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +86 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +265 -0
- data/Rakefile +62 -0
- data/VERSION +1 -0
- data/doc/.nojekyll +0 -0
- data/doc/Dynamoid.html +312 -0
- data/doc/Dynamoid/Adapter.html +1385 -0
- data/doc/Dynamoid/Adapter/AwsSdk.html +1585 -0
- data/doc/Dynamoid/Adapter/Local.html +1574 -0
- data/doc/Dynamoid/Associations.html +131 -0
- data/doc/Dynamoid/Associations/Association.html +794 -0
- data/doc/Dynamoid/Associations/BelongsTo.html +158 -0
- data/doc/Dynamoid/Associations/ClassMethods.html +723 -0
- data/doc/Dynamoid/Associations/HasAndBelongsToMany.html +164 -0
- data/doc/Dynamoid/Associations/HasMany.html +164 -0
- data/doc/Dynamoid/Associations/HasOne.html +158 -0
- data/doc/Dynamoid/Associations/ManyAssociation.html +1640 -0
- data/doc/Dynamoid/Associations/SingleAssociation.html +598 -0
- data/doc/Dynamoid/Components.html +204 -0
- data/doc/Dynamoid/Config.html +395 -0
- data/doc/Dynamoid/Config/Options.html +609 -0
- data/doc/Dynamoid/Criteria.html +131 -0
- data/doc/Dynamoid/Criteria/Chain.html +1063 -0
- data/doc/Dynamoid/Criteria/ClassMethods.html +98 -0
- data/doc/Dynamoid/Document.html +666 -0
- data/doc/Dynamoid/Document/ClassMethods.html +937 -0
- data/doc/Dynamoid/Errors.html +118 -0
- data/doc/Dynamoid/Errors/DocumentNotValid.html +210 -0
- data/doc/Dynamoid/Errors/Error.html +130 -0
- data/doc/Dynamoid/Errors/InvalidField.html +133 -0
- data/doc/Dynamoid/Errors/MissingRangeKey.html +133 -0
- data/doc/Dynamoid/Fields.html +669 -0
- data/doc/Dynamoid/Fields/ClassMethods.html +309 -0
- data/doc/Dynamoid/Finders.html +128 -0
- data/doc/Dynamoid/Finders/ClassMethods.html +516 -0
- data/doc/Dynamoid/Indexes.html +308 -0
- data/doc/Dynamoid/Indexes/ClassMethods.html +353 -0
- data/doc/Dynamoid/Indexes/Index.html +1104 -0
- data/doc/Dynamoid/Persistence.html +651 -0
- data/doc/Dynamoid/Persistence/ClassMethods.html +670 -0
- data/doc/Dynamoid/Validations.html +399 -0
- data/doc/_index.html +461 -0
- data/doc/class_list.html +47 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +55 -0
- data/doc/css/style.css +322 -0
- data/doc/file.LICENSE.html +66 -0
- data/doc/file.README.html +312 -0
- data/doc/file_list.html +52 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +312 -0
- data/doc/js/app.js +205 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +16 -0
- data/doc/method_list.html +1238 -0
- data/doc/top-level-namespace.html +105 -0
- data/lib/dynamoid.rb +47 -0
- data/lib/dynamoid/adapter.rb +177 -0
- data/lib/dynamoid/adapter/aws_sdk.rb +223 -0
- data/lib/dynamoid/associations.rb +106 -0
- data/lib/dynamoid/associations/association.rb +105 -0
- data/lib/dynamoid/associations/belongs_to.rb +44 -0
- data/lib/dynamoid/associations/has_and_belongs_to_many.rb +40 -0
- data/lib/dynamoid/associations/has_many.rb +39 -0
- data/lib/dynamoid/associations/has_one.rb +39 -0
- data/lib/dynamoid/associations/many_association.rb +191 -0
- data/lib/dynamoid/associations/single_association.rb +69 -0
- data/lib/dynamoid/components.rb +36 -0
- data/lib/dynamoid/config.rb +57 -0
- data/lib/dynamoid/config/options.rb +78 -0
- data/lib/dynamoid/criteria.rb +29 -0
- data/lib/dynamoid/criteria/chain.rb +243 -0
- data/lib/dynamoid/dirty.rb +41 -0
- data/lib/dynamoid/document.rb +184 -0
- data/lib/dynamoid/errors.rb +28 -0
- data/lib/dynamoid/fields.rb +130 -0
- data/lib/dynamoid/finders.rb +131 -0
- data/lib/dynamoid/identity_map.rb +96 -0
- data/lib/dynamoid/indexes.rb +69 -0
- data/lib/dynamoid/indexes/index.rb +103 -0
- data/lib/dynamoid/middleware/identity_map.rb +16 -0
- data/lib/dynamoid/persistence.rb +247 -0
- data/lib/dynamoid/validations.rb +36 -0
- data/spec/app/models/address.rb +10 -0
- data/spec/app/models/camel_case.rb +24 -0
- data/spec/app/models/magazine.rb +11 -0
- data/spec/app/models/message.rb +9 -0
- data/spec/app/models/sponsor.rb +8 -0
- data/spec/app/models/subscription.rb +12 -0
- data/spec/app/models/tweet.rb +12 -0
- data/spec/app/models/user.rb +26 -0
- data/spec/dynamoid/adapter/aws_sdk_spec.rb +186 -0
- data/spec/dynamoid/adapter_spec.rb +117 -0
- data/spec/dynamoid/associations/association_spec.rb +194 -0
- data/spec/dynamoid/associations/belongs_to_spec.rb +71 -0
- data/spec/dynamoid/associations/has_and_belongs_to_many_spec.rb +47 -0
- data/spec/dynamoid/associations/has_many_spec.rb +42 -0
- data/spec/dynamoid/associations/has_one_spec.rb +45 -0
- data/spec/dynamoid/associations_spec.rb +16 -0
- data/spec/dynamoid/config_spec.rb +27 -0
- data/spec/dynamoid/criteria/chain_spec.rb +140 -0
- data/spec/dynamoid/criteria_spec.rb +72 -0
- data/spec/dynamoid/dirty_spec.rb +49 -0
- data/spec/dynamoid/document_spec.rb +118 -0
- data/spec/dynamoid/fields_spec.rb +127 -0
- data/spec/dynamoid/finders_spec.rb +135 -0
- data/spec/dynamoid/identity_map_spec.rb +45 -0
- data/spec/dynamoid/indexes/index_spec.rb +104 -0
- data/spec/dynamoid/indexes_spec.rb +25 -0
- data/spec/dynamoid/persistence_spec.rb +176 -0
- data/spec/dynamoid/validations_spec.rb +36 -0
- data/spec/dynamoid_spec.rb +9 -0
- data/spec/spec_helper.rb +50 -0
- metadata +376 -0
@@ -0,0 +1,1574 @@
|
|
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::Adapter::Local
|
8
|
+
|
9
|
+
— 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 (L)</a> »
|
37
|
+
<span class='title'><span class='object_link'><a href="../../Dynamoid.html" title="Dynamoid (module)">Dynamoid</a></span></span> » <span class='title'><span class='object_link'><a href="../Adapter.html" title="Dynamoid::Adapter (module)">Adapter</a></span></span>
|
38
|
+
»
|
39
|
+
<span class="title">Local</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::Adapter::Local
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
</h1>
|
64
|
+
|
65
|
+
<dl class="box">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<dt class="r1">Extended by:</dt>
|
70
|
+
<dd class="r1"><span class='object_link'><a href="" title="Dynamoid::Adapter::Local (module)">Local</a></span></dd>
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
<dt class="r2">Included in:</dt>
|
78
|
+
<dd class="r2"><span class='object_link'><a href="" title="Dynamoid::Adapter::Local (module)">Local</a></span></dd>
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
<dt class="r1 last">Defined in:</dt>
|
83
|
+
<dd class="r1 last">lib/dynamoid/adapter/local.rb</dd>
|
84
|
+
|
85
|
+
</dl>
|
86
|
+
<div class="clear"></div>
|
87
|
+
|
88
|
+
<h2>Overview</h2><div class="docstring">
|
89
|
+
<div class="discussion">
|
90
|
+
<p>This gimpy hash construct should be equivalent to Amazon's actual DynamoDB, for offline development.
|
91
|
+
All tests pass with either this or connecting to the real DynamoDB, and that's good enough for me.</p>
|
92
|
+
|
93
|
+
|
94
|
+
</div>
|
95
|
+
</div>
|
96
|
+
<div class="tags">
|
97
|
+
|
98
|
+
|
99
|
+
</div>
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<h2>
|
108
|
+
Instance Method Summary
|
109
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
110
|
+
</h2>
|
111
|
+
|
112
|
+
<ul class="summary">
|
113
|
+
|
114
|
+
<li class="public ">
|
115
|
+
<span class="summary_signature">
|
116
|
+
|
117
|
+
<a href="#batch_get_item-instance_method" title="#batch_get_item (instance method)">- (Hash) <strong>batch_get_item</strong>(options) </a>
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
</span>
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
<span class="summary_desc"><div class='inline'><p>Get many items at once from the hash.</p>
|
131
|
+
</div></span>
|
132
|
+
|
133
|
+
</li>
|
134
|
+
|
135
|
+
|
136
|
+
<li class="public ">
|
137
|
+
<span class="summary_signature">
|
138
|
+
|
139
|
+
<a href="#create_table-instance_method" title="#create_table (instance method)">- (Object) <strong>create_table</strong>(table_name, key, options = {}) </a>
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
</span>
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
<span class="summary_desc"><div class='inline'><p>Create a table.</p>
|
153
|
+
</div></span>
|
154
|
+
|
155
|
+
</li>
|
156
|
+
|
157
|
+
|
158
|
+
<li class="public ">
|
159
|
+
<span class="summary_signature">
|
160
|
+
|
161
|
+
<a href="#data-instance_method" title="#data (instance method)">- (Hash) <strong>data</strong> </a>
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
</span>
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
<span class="summary_desc"><div class='inline'><p>The hash holding all of our data.</p>
|
175
|
+
</div></span>
|
176
|
+
|
177
|
+
</li>
|
178
|
+
|
179
|
+
|
180
|
+
<li class="public ">
|
181
|
+
<span class="summary_signature">
|
182
|
+
|
183
|
+
<a href="#delete_item-instance_method" title="#delete_item (instance method)">- (Object) <strong>delete_item</strong>(table_name, key, options = {}) </a>
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
</span>
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
<span class="summary_desc"><div class='inline'><p>Removes an item from the hash.</p>
|
197
|
+
</div></span>
|
198
|
+
|
199
|
+
</li>
|
200
|
+
|
201
|
+
|
202
|
+
<li class="public ">
|
203
|
+
<span class="summary_signature">
|
204
|
+
|
205
|
+
<a href="#delete_table-instance_method" title="#delete_table (instance method)">- (Object) <strong>delete_table</strong>(table_name) </a>
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
</span>
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
<span class="summary_desc"><div class='inline'><p>Deletes an entire table from the hash.</p>
|
219
|
+
</div></span>
|
220
|
+
|
221
|
+
</li>
|
222
|
+
|
223
|
+
|
224
|
+
<li class="public ">
|
225
|
+
<span class="summary_signature">
|
226
|
+
|
227
|
+
<a href="#drop_till_start-instance_method" title="#drop_till_start (instance method)">- (Object) <strong>drop_till_start</strong>(results, next_token, range_key, hash_key) </a>
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
</span>
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
241
|
+
|
242
|
+
</li>
|
243
|
+
|
244
|
+
|
245
|
+
<li class="public ">
|
246
|
+
<span class="summary_signature">
|
247
|
+
|
248
|
+
<a href="#get_item-instance_method" title="#get_item (instance method)">- (Hash) <strong>get_item</strong>(table_name, key, options = {}) </a>
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
</span>
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
<span class="summary_desc"><div class='inline'><p>Fetches an item from the hash.</p>
|
262
|
+
</div></span>
|
263
|
+
|
264
|
+
</li>
|
265
|
+
|
266
|
+
|
267
|
+
<li class="public ">
|
268
|
+
<span class="summary_signature">
|
269
|
+
|
270
|
+
<a href="#list_tables-instance_method" title="#list_tables (instance method)">- (Object) <strong>list_tables</strong> </a>
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
</span>
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
<span class="summary_desc"><div class='inline'><p>List all tables on DynamoDB.</p>
|
284
|
+
</div></span>
|
285
|
+
|
286
|
+
</li>
|
287
|
+
|
288
|
+
|
289
|
+
<li class="public ">
|
290
|
+
<span class="summary_signature">
|
291
|
+
|
292
|
+
<a href="#put_item-instance_method" title="#put_item (instance method)">- (Object) <strong>put_item</strong>(table_name, object) </a>
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
</span>
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
<span class="summary_desc"><div class='inline'><p>Persists an item in the hash.</p>
|
306
|
+
</div></span>
|
307
|
+
|
308
|
+
</li>
|
309
|
+
|
310
|
+
|
311
|
+
<li class="public ">
|
312
|
+
<span class="summary_signature">
|
313
|
+
|
314
|
+
<a href="#query-instance_method" title="#query (instance method)">- (Array) <strong>query</strong>(table_name, opts = {}) </a>
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
</span>
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
<span class="summary_desc"><div class='inline'><p>Query the hash.</p>
|
328
|
+
</div></span>
|
329
|
+
|
330
|
+
</li>
|
331
|
+
|
332
|
+
|
333
|
+
<li class="public ">
|
334
|
+
<span class="summary_signature">
|
335
|
+
|
336
|
+
<a href="#reset_data-instance_method" title="#reset_data (instance method)">- (Object) <strong>reset_data</strong> </a>
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
</span>
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
<span class="summary_desc"><div class='inline'><p>A convenience method for testing that destroys all table data without destroying their structure.</p>
|
350
|
+
</div></span>
|
351
|
+
|
352
|
+
</li>
|
353
|
+
|
354
|
+
|
355
|
+
<li class="public ">
|
356
|
+
<span class="summary_signature">
|
357
|
+
|
358
|
+
<a href="#scan-instance_method" title="#scan (instance method)">- (Array) <strong>scan</strong>(table_name, scan_hash, opts = {}) </a>
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
</span>
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
<span class="summary_desc"><div class='inline'><p>Scan the hash.</p>
|
372
|
+
</div></span>
|
373
|
+
|
374
|
+
</li>
|
375
|
+
|
376
|
+
|
377
|
+
</ul>
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
<div id="instance_method_details" class="method_details_list">
|
383
|
+
<h2>Instance Method Details</h2>
|
384
|
+
|
385
|
+
|
386
|
+
<div class="method_details first">
|
387
|
+
<p class="signature first" id="batch_get_item-instance_method">
|
388
|
+
|
389
|
+
- (<tt>Hash</tt>) <strong>batch_get_item</strong>(options)
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
</p><div class="docstring">
|
394
|
+
<div class="discussion">
|
395
|
+
<p>Get many items at once from the hash.</p>
|
396
|
+
|
397
|
+
|
398
|
+
</div>
|
399
|
+
</div>
|
400
|
+
<div class="tags">
|
401
|
+
|
402
|
+
<div class="examples">
|
403
|
+
<h3>Examples:</h3>
|
404
|
+
|
405
|
+
<h4><div class='inline'><p>Retrieve IDs 1 and 2 from the table testtable</p>
|
406
|
+
</div></h4>
|
407
|
+
<pre class="example code"><span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='op'>::</span><span class='const'>Local</span><span class='period'>.</span><span class='id identifier rubyid_batch_get_item'>batch_get_item</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>table1</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>2</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='rparen'>)</span></pre>
|
408
|
+
|
409
|
+
</div>
|
410
|
+
<h3>Parameters:</h3>
|
411
|
+
<ul class="param">
|
412
|
+
|
413
|
+
<li>
|
414
|
+
|
415
|
+
<span class='name'>options</span>
|
416
|
+
|
417
|
+
|
418
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
—
|
423
|
+
<div class='inline'><p>the hash of tables and IDs to retrieve</p>
|
424
|
+
</div>
|
425
|
+
|
426
|
+
</li>
|
427
|
+
|
428
|
+
</ul>
|
429
|
+
|
430
|
+
<h3>Returns:</h3>
|
431
|
+
<ul class="return">
|
432
|
+
|
433
|
+
<li>
|
434
|
+
|
435
|
+
|
436
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
—
|
441
|
+
<div class='inline'><p>a hash where keys are the table names and the values are the retrieved items</p>
|
442
|
+
</div>
|
443
|
+
|
444
|
+
</li>
|
445
|
+
|
446
|
+
</ul>
|
447
|
+
<h3>Since:</h3>
|
448
|
+
<ul class="since">
|
449
|
+
|
450
|
+
<li>
|
451
|
+
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
<div class='inline'><p>0.2.0</p>
|
457
|
+
</div>
|
458
|
+
|
459
|
+
</li>
|
460
|
+
|
461
|
+
</ul>
|
462
|
+
|
463
|
+
</div><table class="source_code">
|
464
|
+
<tr>
|
465
|
+
<td>
|
466
|
+
<pre class="lines">
|
467
|
+
|
468
|
+
|
469
|
+
35
|
470
|
+
36
|
471
|
+
37
|
472
|
+
38
|
473
|
+
39
|
474
|
+
40
|
475
|
+
41
|
476
|
+
42
|
477
|
+
43
|
478
|
+
44
|
479
|
+
45
|
480
|
+
46
|
481
|
+
47
|
482
|
+
48
|
483
|
+
49
|
484
|
+
50</pre>
|
485
|
+
</td>
|
486
|
+
<td>
|
487
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter/local.rb', line 35</span>
|
488
|
+
|
489
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_batch_get_item'>batch_get_item</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
490
|
+
<span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_h'>h</span><span class='comma'>,</span> <span class='id identifier rubyid_k'>k</span><span class='op'>|</span> <span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='const'>Array</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</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>
|
491
|
+
<span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_keys'>keys</span><span class='op'>|</span>
|
492
|
+
<span class='id identifier rubyid_table'>table</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span>
|
493
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_table'>table</span><span class='lbracket'>[</span><span class='symbol'>:range_key</span><span class='rbracket'>]</span>
|
494
|
+
<span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_keys'>keys</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_hash_key'>hash_key</span><span class='comma'>,</span> <span class='id identifier rubyid_range_key'>range_key</span><span class='op'>|</span>
|
495
|
+
<span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span> <span class='op'><<</span> <span class='id identifier rubyid_get_item'>get_item</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_hash_key'>hash_key</span><span class='comma'>,</span> <span class='symbol'>:range_key</span> <span class='op'>=></span> <span class='id identifier rubyid_range_key'>range_key</span><span class='rparen'>)</span>
|
496
|
+
<span class='kw'>end</span>
|
497
|
+
<span class='kw'>else</span>
|
498
|
+
<span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_keys'>keys</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='op'>|</span>
|
499
|
+
<span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span> <span class='op'><<</span> <span class='id identifier rubyid_get_item'>get_item</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
500
|
+
<span class='kw'>end</span>
|
501
|
+
<span class='kw'>end</span>
|
502
|
+
<span class='kw'>end</span>
|
503
|
+
<span class='kw'>end</span>
|
504
|
+
<span class='kw'>end</span></pre>
|
505
|
+
</td>
|
506
|
+
</tr>
|
507
|
+
</table>
|
508
|
+
</div>
|
509
|
+
|
510
|
+
<div class="method_details ">
|
511
|
+
<p class="signature " id="create_table-instance_method">
|
512
|
+
|
513
|
+
- (<tt>Object</tt>) <strong>create_table</strong>(table_name, key, options = {})
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
</p><div class="docstring">
|
518
|
+
<div class="discussion">
|
519
|
+
<p>Create a table.</p>
|
520
|
+
|
521
|
+
|
522
|
+
</div>
|
523
|
+
</div>
|
524
|
+
<div class="tags">
|
525
|
+
<h3>Parameters:</h3>
|
526
|
+
<ul class="param">
|
527
|
+
|
528
|
+
<li>
|
529
|
+
|
530
|
+
<span class='name'>table_name</span>
|
531
|
+
|
532
|
+
|
533
|
+
<span class='type'>(<tt>String</tt>)</span>
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
—
|
538
|
+
<div class='inline'><p>the name of the table to create</p>
|
539
|
+
</div>
|
540
|
+
|
541
|
+
</li>
|
542
|
+
|
543
|
+
<li>
|
544
|
+
|
545
|
+
<span class='name'>key</span>
|
546
|
+
|
547
|
+
|
548
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
—
|
553
|
+
<div class='inline'><p>the table's primary key (defaults to :id)</p>
|
554
|
+
</div>
|
555
|
+
|
556
|
+
</li>
|
557
|
+
|
558
|
+
<li>
|
559
|
+
|
560
|
+
<span class='name'>options</span>
|
561
|
+
|
562
|
+
|
563
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
564
|
+
|
565
|
+
|
566
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
567
|
+
|
568
|
+
|
569
|
+
—
|
570
|
+
<div class='inline'><p>provide a range_key here if you want one for the table</p>
|
571
|
+
</div>
|
572
|
+
|
573
|
+
</li>
|
574
|
+
|
575
|
+
</ul>
|
576
|
+
|
577
|
+
<h3>Since:</h3>
|
578
|
+
<ul class="since">
|
579
|
+
|
580
|
+
<li>
|
581
|
+
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
|
586
|
+
<div class='inline'><p>0.2.0</p>
|
587
|
+
</div>
|
588
|
+
|
589
|
+
</li>
|
590
|
+
|
591
|
+
</ul>
|
592
|
+
|
593
|
+
</div><table class="source_code">
|
594
|
+
<tr>
|
595
|
+
<td>
|
596
|
+
<pre class="lines">
|
597
|
+
|
598
|
+
|
599
|
+
59
|
600
|
+
60
|
601
|
+
61
|
602
|
+
62</pre>
|
603
|
+
</td>
|
604
|
+
<td>
|
605
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter/local.rb', line 59</span>
|
606
|
+
|
607
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_create_table'>create_table</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</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>
|
608
|
+
<span class='id identifier rubyid_range_key'>range_key</span> <span class='op'>=</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='op'>&&</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='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
609
|
+
<span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='symbol'>:hash_key</span> <span class='op'>=></span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='symbol'>:range_key</span> <span class='op'>=></span> <span class='id identifier rubyid_range_key'>range_key</span><span class='comma'>,</span> <span class='symbol'>:data</span> <span class='op'>=></span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rbrace'>}</span>
|
610
|
+
<span class='kw'>end</span></pre>
|
611
|
+
</td>
|
612
|
+
</tr>
|
613
|
+
</table>
|
614
|
+
</div>
|
615
|
+
|
616
|
+
<div class="method_details ">
|
617
|
+
<p class="signature " id="data-instance_method">
|
618
|
+
|
619
|
+
- (<tt>Hash</tt>) <strong>data</strong>
|
620
|
+
|
621
|
+
|
622
|
+
|
623
|
+
</p><div class="docstring">
|
624
|
+
<div class="discussion">
|
625
|
+
<p>The hash holding all of our data.</p>
|
626
|
+
|
627
|
+
|
628
|
+
</div>
|
629
|
+
</div>
|
630
|
+
<div class="tags">
|
631
|
+
|
632
|
+
<h3>Returns:</h3>
|
633
|
+
<ul class="return">
|
634
|
+
|
635
|
+
<li>
|
636
|
+
|
637
|
+
|
638
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
639
|
+
|
640
|
+
|
641
|
+
|
642
|
+
—
|
643
|
+
<div class='inline'><p>a hash of raw values</p>
|
644
|
+
</div>
|
645
|
+
|
646
|
+
</li>
|
647
|
+
|
648
|
+
</ul>
|
649
|
+
<h3>Since:</h3>
|
650
|
+
<ul class="since">
|
651
|
+
|
652
|
+
<li>
|
653
|
+
|
654
|
+
|
655
|
+
|
656
|
+
|
657
|
+
|
658
|
+
<div class='inline'><p>0.2.0</p>
|
659
|
+
</div>
|
660
|
+
|
661
|
+
</li>
|
662
|
+
|
663
|
+
</ul>
|
664
|
+
|
665
|
+
</div><table class="source_code">
|
666
|
+
<tr>
|
667
|
+
<td>
|
668
|
+
<pre class="lines">
|
669
|
+
|
670
|
+
|
671
|
+
14
|
672
|
+
15
|
673
|
+
16</pre>
|
674
|
+
</td>
|
675
|
+
<td>
|
676
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter/local.rb', line 14</span>
|
677
|
+
|
678
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_data'>data</span>
|
679
|
+
<span class='ivar'>@data</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
680
|
+
<span class='kw'>end</span></pre>
|
681
|
+
</td>
|
682
|
+
</tr>
|
683
|
+
</table>
|
684
|
+
</div>
|
685
|
+
|
686
|
+
<div class="method_details ">
|
687
|
+
<p class="signature " id="delete_item-instance_method">
|
688
|
+
|
689
|
+
- (<tt>Object</tt>) <strong>delete_item</strong>(table_name, key, options = {})
|
690
|
+
|
691
|
+
|
692
|
+
|
693
|
+
</p><div class="docstring">
|
694
|
+
<div class="discussion">
|
695
|
+
<p>Removes an item from the hash.</p>
|
696
|
+
|
697
|
+
|
698
|
+
</div>
|
699
|
+
</div>
|
700
|
+
<div class="tags">
|
701
|
+
<h3>Parameters:</h3>
|
702
|
+
<ul class="param">
|
703
|
+
|
704
|
+
<li>
|
705
|
+
|
706
|
+
<span class='name'>table_name</span>
|
707
|
+
|
708
|
+
|
709
|
+
<span class='type'>(<tt>String</tt>)</span>
|
710
|
+
|
711
|
+
|
712
|
+
|
713
|
+
—
|
714
|
+
<div class='inline'><p>the name of the table</p>
|
715
|
+
</div>
|
716
|
+
|
717
|
+
</li>
|
718
|
+
|
719
|
+
<li>
|
720
|
+
|
721
|
+
<span class='name'>key</span>
|
722
|
+
|
723
|
+
|
724
|
+
<span class='type'>(<tt>String</tt>)</span>
|
725
|
+
|
726
|
+
|
727
|
+
|
728
|
+
—
|
729
|
+
<div class='inline'><p>the hash key of the item to delete</p>
|
730
|
+
</div>
|
731
|
+
|
732
|
+
</li>
|
733
|
+
|
734
|
+
<li>
|
735
|
+
|
736
|
+
<span class='name'>range_key</span>
|
737
|
+
|
738
|
+
|
739
|
+
<span class='type'>(<tt>Number</tt>)</span>
|
740
|
+
|
741
|
+
|
742
|
+
|
743
|
+
—
|
744
|
+
<div class='inline'><p>the range key of the item to delete, required if the table has a composite key</p>
|
745
|
+
</div>
|
746
|
+
|
747
|
+
</li>
|
748
|
+
|
749
|
+
</ul>
|
750
|
+
|
751
|
+
<h3>Since:</h3>
|
752
|
+
<ul class="since">
|
753
|
+
|
754
|
+
<li>
|
755
|
+
|
756
|
+
|
757
|
+
|
758
|
+
|
759
|
+
|
760
|
+
<div class='inline'><p>0.2.0</p>
|
761
|
+
</div>
|
762
|
+
|
763
|
+
</li>
|
764
|
+
|
765
|
+
</ul>
|
766
|
+
|
767
|
+
</div><table class="source_code">
|
768
|
+
<tr>
|
769
|
+
<td>
|
770
|
+
<pre class="lines">
|
771
|
+
|
772
|
+
|
773
|
+
71
|
774
|
+
72
|
775
|
+
73
|
776
|
+
74</pre>
|
777
|
+
</td>
|
778
|
+
<td>
|
779
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter/local.rb', line 71</span>
|
780
|
+
|
781
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_delete_item'>delete_item</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</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>
|
782
|
+
<span class='id identifier rubyid_range_key'>range_key</span> <span class='op'>=</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_key</span><span class='rparen'>)</span>
|
783
|
+
<span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_range_key'>range_key</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
784
|
+
<span class='kw'>end</span></pre>
|
785
|
+
</td>
|
786
|
+
</tr>
|
787
|
+
</table>
|
788
|
+
</div>
|
789
|
+
|
790
|
+
<div class="method_details ">
|
791
|
+
<p class="signature " id="delete_table-instance_method">
|
792
|
+
|
793
|
+
- (<tt>Object</tt>) <strong>delete_table</strong>(table_name)
|
794
|
+
|
795
|
+
|
796
|
+
|
797
|
+
</p><div class="docstring">
|
798
|
+
<div class="discussion">
|
799
|
+
<p>Deletes an entire table from the hash.</p>
|
800
|
+
|
801
|
+
|
802
|
+
</div>
|
803
|
+
</div>
|
804
|
+
<div class="tags">
|
805
|
+
<h3>Parameters:</h3>
|
806
|
+
<ul class="param">
|
807
|
+
|
808
|
+
<li>
|
809
|
+
|
810
|
+
<span class='name'>table_name</span>
|
811
|
+
|
812
|
+
|
813
|
+
<span class='type'>(<tt>String</tt>)</span>
|
814
|
+
|
815
|
+
|
816
|
+
|
817
|
+
—
|
818
|
+
<div class='inline'><p>the name of the table to destroy</p>
|
819
|
+
</div>
|
820
|
+
|
821
|
+
</li>
|
822
|
+
|
823
|
+
</ul>
|
824
|
+
|
825
|
+
<h3>Since:</h3>
|
826
|
+
<ul class="since">
|
827
|
+
|
828
|
+
<li>
|
829
|
+
|
830
|
+
|
831
|
+
|
832
|
+
|
833
|
+
|
834
|
+
<div class='inline'><p>0.2.0</p>
|
835
|
+
</div>
|
836
|
+
|
837
|
+
</li>
|
838
|
+
|
839
|
+
</ul>
|
840
|
+
|
841
|
+
</div><table class="source_code">
|
842
|
+
<tr>
|
843
|
+
<td>
|
844
|
+
<pre class="lines">
|
845
|
+
|
846
|
+
|
847
|
+
81
|
848
|
+
82
|
849
|
+
83</pre>
|
850
|
+
</td>
|
851
|
+
<td>
|
852
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter/local.rb', line 81</span>
|
853
|
+
|
854
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_delete_table'>delete_table</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
855
|
+
<span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
856
|
+
<span class='kw'>end</span></pre>
|
857
|
+
</td>
|
858
|
+
</tr>
|
859
|
+
</table>
|
860
|
+
</div>
|
861
|
+
|
862
|
+
<div class="method_details ">
|
863
|
+
<p class="signature " id="drop_till_start-instance_method">
|
864
|
+
|
865
|
+
- (<tt>Object</tt>) <strong>drop_till_start</strong>(results, next_token, range_key, hash_key)
|
866
|
+
|
867
|
+
|
868
|
+
|
869
|
+
</p><table class="source_code">
|
870
|
+
<tr>
|
871
|
+
<td>
|
872
|
+
<pre class="lines">
|
873
|
+
|
874
|
+
|
875
|
+
180
|
876
|
+
181
|
877
|
+
182
|
878
|
+
183
|
879
|
+
184
|
880
|
+
185
|
881
|
+
186
|
882
|
+
187
|
883
|
+
188
|
884
|
+
189</pre>
|
885
|
+
</td>
|
886
|
+
<td>
|
887
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter/local.rb', line 180</span>
|
888
|
+
|
889
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_drop_till_start'>drop_till_start</span><span class='lparen'>(</span><span class='id identifier rubyid_results'>results</span><span class='comma'>,</span> <span class='id identifier rubyid_next_token'>next_token</span><span class='comma'>,</span> <span class='id identifier rubyid_range_key'>range_key</span><span class='comma'>,</span> <span class='id identifier rubyid_hash_key'>hash_key</span><span class='rparen'>)</span>
|
890
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_results'>results</span> <span class='kw'>unless</span> <span class='id identifier rubyid_next_token'>next_token</span>
|
891
|
+
|
892
|
+
<span class='id identifier rubyid_hash_value'>hash_value</span> <span class='op'>=</span> <span class='id identifier rubyid_next_token'>next_token</span><span class='lbracket'>[</span><span class='symbol'>:hash_key_element</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
893
|
+
<span class='id identifier rubyid_range_value'>range_value</span> <span class='op'>=</span> <span class='id identifier rubyid_next_token'>next_token</span><span class='lbracket'>[</span><span class='symbol'>:range_key_element</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='kw'>if</span> <span class='id identifier rubyid_next_token'>next_token</span><span class='lbracket'>[</span><span class='symbol'>:range_key_element</span><span class='rbracket'>]</span>
|
894
|
+
|
895
|
+
<span class='id identifier rubyid_results'>results</span> <span class='op'>=</span> <span class='id identifier rubyid_results'>results</span><span class='period'>.</span><span class='id identifier rubyid_drop_while'>drop_while</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_r'>r</span><span class='op'>|</span>
|
896
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_r'>r</span><span class='lbracket'>[</span><span class='id identifier rubyid_hash_key'>hash_key</span><span class='rbracket'>]</span> <span class='op'>!=</span> <span class='id identifier rubyid_hash_value'>hash_value</span> <span class='kw'>or</span> <span class='id identifier rubyid_r'>r</span><span class='lbracket'>[</span><span class='id identifier rubyid_range_key'>range_key</span><span class='rbracket'>]</span> <span class='op'>!=</span> <span class='id identifier rubyid_range_value'>range_value</span><span class='rparen'>)</span>
|
897
|
+
<span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_drop'>drop</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
|
898
|
+
<span class='kw'>end</span></pre>
|
899
|
+
</td>
|
900
|
+
</tr>
|
901
|
+
</table>
|
902
|
+
</div>
|
903
|
+
|
904
|
+
<div class="method_details ">
|
905
|
+
<p class="signature " id="get_item-instance_method">
|
906
|
+
|
907
|
+
- (<tt>Hash</tt>) <strong>get_item</strong>(table_name, key, options = {})
|
908
|
+
|
909
|
+
|
910
|
+
|
911
|
+
</p><div class="docstring">
|
912
|
+
<div class="discussion">
|
913
|
+
<p>Fetches an item from the hash.</p>
|
914
|
+
|
915
|
+
|
916
|
+
</div>
|
917
|
+
</div>
|
918
|
+
<div class="tags">
|
919
|
+
<h3>Parameters:</h3>
|
920
|
+
<ul class="param">
|
921
|
+
|
922
|
+
<li>
|
923
|
+
|
924
|
+
<span class='name'>table_name</span>
|
925
|
+
|
926
|
+
|
927
|
+
<span class='type'>(<tt>String</tt>)</span>
|
928
|
+
|
929
|
+
|
930
|
+
|
931
|
+
—
|
932
|
+
<div class='inline'><p>the name of the table</p>
|
933
|
+
</div>
|
934
|
+
|
935
|
+
</li>
|
936
|
+
|
937
|
+
<li>
|
938
|
+
|
939
|
+
<span class='name'>key</span>
|
940
|
+
|
941
|
+
|
942
|
+
<span class='type'>(<tt>String</tt>)</span>
|
943
|
+
|
944
|
+
|
945
|
+
|
946
|
+
—
|
947
|
+
<div class='inline'><p>the hash key of the item to find</p>
|
948
|
+
</div>
|
949
|
+
|
950
|
+
</li>
|
951
|
+
|
952
|
+
<li>
|
953
|
+
|
954
|
+
<span class='name'>range_key</span>
|
955
|
+
|
956
|
+
|
957
|
+
<span class='type'>(<tt>Number</tt>)</span>
|
958
|
+
|
959
|
+
|
960
|
+
|
961
|
+
—
|
962
|
+
<div class='inline'><p>the range key of the item to find, required if the table has a composite key</p>
|
963
|
+
</div>
|
964
|
+
|
965
|
+
</li>
|
966
|
+
|
967
|
+
</ul>
|
968
|
+
|
969
|
+
<h3>Returns:</h3>
|
970
|
+
<ul class="return">
|
971
|
+
|
972
|
+
<li>
|
973
|
+
|
974
|
+
|
975
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
976
|
+
|
977
|
+
|
978
|
+
|
979
|
+
—
|
980
|
+
<div class='inline'><p>a hash representing the raw item</p>
|
981
|
+
</div>
|
982
|
+
|
983
|
+
</li>
|
984
|
+
|
985
|
+
</ul>
|
986
|
+
<h3>Since:</h3>
|
987
|
+
<ul class="since">
|
988
|
+
|
989
|
+
<li>
|
990
|
+
|
991
|
+
|
992
|
+
|
993
|
+
|
994
|
+
|
995
|
+
<div class='inline'><p>0.2.0</p>
|
996
|
+
</div>
|
997
|
+
|
998
|
+
</li>
|
999
|
+
|
1000
|
+
</ul>
|
1001
|
+
|
1002
|
+
</div><table class="source_code">
|
1003
|
+
<tr>
|
1004
|
+
<td>
|
1005
|
+
<pre class="lines">
|
1006
|
+
|
1007
|
+
|
1008
|
+
96
|
1009
|
+
97
|
1010
|
+
98
|
1011
|
+
99
|
1012
|
+
100
|
1013
|
+
101
|
1014
|
+
102
|
1015
|
+
103</pre>
|
1016
|
+
</td>
|
1017
|
+
<td>
|
1018
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter/local.rb', line 96</span>
|
1019
|
+
|
1020
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_get_item'>get_item</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</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>
|
1021
|
+
<span class='id identifier rubyid_range_key'>range_key</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:range_key</span><span class='rbracket'>]</span>
|
1022
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span>
|
1023
|
+
<span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_range_key'>range_key</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span>
|
1024
|
+
<span class='kw'>else</span>
|
1025
|
+
<span class='kw'>nil</span>
|
1026
|
+
<span class='kw'>end</span>
|
1027
|
+
<span class='kw'>end</span></pre>
|
1028
|
+
</td>
|
1029
|
+
</tr>
|
1030
|
+
</table>
|
1031
|
+
</div>
|
1032
|
+
|
1033
|
+
<div class="method_details ">
|
1034
|
+
<p class="signature " id="list_tables-instance_method">
|
1035
|
+
|
1036
|
+
- (<tt>Object</tt>) <strong>list_tables</strong>
|
1037
|
+
|
1038
|
+
|
1039
|
+
|
1040
|
+
</p><div class="docstring">
|
1041
|
+
<div class="discussion">
|
1042
|
+
<p>List all tables on DynamoDB.</p>
|
1043
|
+
|
1044
|
+
|
1045
|
+
</div>
|
1046
|
+
</div>
|
1047
|
+
<div class="tags">
|
1048
|
+
|
1049
|
+
<h3>Since:</h3>
|
1050
|
+
<ul class="since">
|
1051
|
+
|
1052
|
+
<li>
|
1053
|
+
|
1054
|
+
|
1055
|
+
|
1056
|
+
|
1057
|
+
|
1058
|
+
<div class='inline'><p>0.2.0</p>
|
1059
|
+
</div>
|
1060
|
+
|
1061
|
+
</li>
|
1062
|
+
|
1063
|
+
</ul>
|
1064
|
+
|
1065
|
+
</div><table class="source_code">
|
1066
|
+
<tr>
|
1067
|
+
<td>
|
1068
|
+
<pre class="lines">
|
1069
|
+
|
1070
|
+
|
1071
|
+
108
|
1072
|
+
109
|
1073
|
+
110</pre>
|
1074
|
+
</td>
|
1075
|
+
<td>
|
1076
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter/local.rb', line 108</span>
|
1077
|
+
|
1078
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_list_tables'>list_tables</span>
|
1079
|
+
<span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span>
|
1080
|
+
<span class='kw'>end</span></pre>
|
1081
|
+
</td>
|
1082
|
+
</tr>
|
1083
|
+
</table>
|
1084
|
+
</div>
|
1085
|
+
|
1086
|
+
<div class="method_details ">
|
1087
|
+
<p class="signature " id="put_item-instance_method">
|
1088
|
+
|
1089
|
+
- (<tt>Object</tt>) <strong>put_item</strong>(table_name, object)
|
1090
|
+
|
1091
|
+
|
1092
|
+
|
1093
|
+
</p><div class="docstring">
|
1094
|
+
<div class="discussion">
|
1095
|
+
<p>Persists an item in the hash.</p>
|
1096
|
+
|
1097
|
+
|
1098
|
+
</div>
|
1099
|
+
</div>
|
1100
|
+
<div class="tags">
|
1101
|
+
<h3>Parameters:</h3>
|
1102
|
+
<ul class="param">
|
1103
|
+
|
1104
|
+
<li>
|
1105
|
+
|
1106
|
+
<span class='name'>table_name</span>
|
1107
|
+
|
1108
|
+
|
1109
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1110
|
+
|
1111
|
+
|
1112
|
+
|
1113
|
+
—
|
1114
|
+
<div class='inline'><p>the name of the table</p>
|
1115
|
+
</div>
|
1116
|
+
|
1117
|
+
</li>
|
1118
|
+
|
1119
|
+
<li>
|
1120
|
+
|
1121
|
+
<span class='name'>object</span>
|
1122
|
+
|
1123
|
+
|
1124
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
1125
|
+
|
1126
|
+
|
1127
|
+
|
1128
|
+
—
|
1129
|
+
<div class='inline'><p>a hash or Dynamoid object to persist</p>
|
1130
|
+
</div>
|
1131
|
+
|
1132
|
+
</li>
|
1133
|
+
|
1134
|
+
</ul>
|
1135
|
+
|
1136
|
+
<h3>Since:</h3>
|
1137
|
+
<ul class="since">
|
1138
|
+
|
1139
|
+
<li>
|
1140
|
+
|
1141
|
+
|
1142
|
+
|
1143
|
+
|
1144
|
+
|
1145
|
+
<div class='inline'><p>0.2.0</p>
|
1146
|
+
</div>
|
1147
|
+
|
1148
|
+
</li>
|
1149
|
+
|
1150
|
+
</ul>
|
1151
|
+
|
1152
|
+
</div><table class="source_code">
|
1153
|
+
<tr>
|
1154
|
+
<td>
|
1155
|
+
<pre class="lines">
|
1156
|
+
|
1157
|
+
|
1158
|
+
118
|
1159
|
+
119
|
1160
|
+
120
|
1161
|
+
121
|
1162
|
+
122
|
1163
|
+
123
|
1164
|
+
124</pre>
|
1165
|
+
</td>
|
1166
|
+
<td>
|
1167
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter/local.rb', line 118</span>
|
1168
|
+
|
1169
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_put_item'>put_item</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
|
1170
|
+
<span class='id identifier rubyid_table'>table</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span>
|
1171
|
+
<span class='id identifier rubyid_table'>table</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_object'>object</span><span class='lbracket'>[</span><span class='id identifier rubyid_table'>table</span><span class='lbracket'>[</span><span class='symbol'>:hash_key</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
|
1172
|
+
<span class='id identifier rubyid_table'>table</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_object'>object</span><span class='lbracket'>[</span><span class='id identifier rubyid_table'>table</span><span class='lbracket'>[</span><span class='symbol'>:hash_key</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_object'>object</span><span class='lbracket'>[</span><span class='id identifier rubyid_table'>table</span><span class='lbracket'>[</span><span class='symbol'>:range_key</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_delete_if'>delete_if</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_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</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_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:empty?</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span><span class='rparen'>)</span><span class='rbrace'>}</span>
|
1173
|
+
<span class='kw'>rescue</span>
|
1174
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
|
1175
|
+
<span class='kw'>end</span></pre>
|
1176
|
+
</td>
|
1177
|
+
</tr>
|
1178
|
+
</table>
|
1179
|
+
</div>
|
1180
|
+
|
1181
|
+
<div class="method_details ">
|
1182
|
+
<p class="signature " id="query-instance_method">
|
1183
|
+
|
1184
|
+
- (<tt>Array</tt>) <strong>query</strong>(table_name, opts = {})
|
1185
|
+
|
1186
|
+
|
1187
|
+
|
1188
|
+
</p><div class="docstring">
|
1189
|
+
<div class="discussion">
|
1190
|
+
<p>Query the hash.</p>
|
1191
|
+
|
1192
|
+
|
1193
|
+
</div>
|
1194
|
+
</div>
|
1195
|
+
<div class="tags">
|
1196
|
+
<h3>Parameters:</h3>
|
1197
|
+
<ul class="param">
|
1198
|
+
|
1199
|
+
<li>
|
1200
|
+
|
1201
|
+
<span class='name'>table_name</span>
|
1202
|
+
|
1203
|
+
|
1204
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1205
|
+
|
1206
|
+
|
1207
|
+
|
1208
|
+
—
|
1209
|
+
<div class='inline'><p>the name of the table</p>
|
1210
|
+
</div>
|
1211
|
+
|
1212
|
+
</li>
|
1213
|
+
|
1214
|
+
<li>
|
1215
|
+
|
1216
|
+
<span class='name'>opts</span>
|
1217
|
+
|
1218
|
+
|
1219
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1220
|
+
|
1221
|
+
|
1222
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
1223
|
+
|
1224
|
+
|
1225
|
+
—
|
1226
|
+
<div class='inline'><p>the options to query the table with</p>
|
1227
|
+
</div>
|
1228
|
+
|
1229
|
+
</li>
|
1230
|
+
|
1231
|
+
</ul>
|
1232
|
+
|
1233
|
+
|
1234
|
+
|
1235
|
+
|
1236
|
+
|
1237
|
+
|
1238
|
+
<h3>Options Hash (<tt>opts</tt>):</h3>
|
1239
|
+
<ul class="option">
|
1240
|
+
|
1241
|
+
<li>
|
1242
|
+
<span class="name">:hash_value</span>
|
1243
|
+
<span class="type">(<tt>String</tt>)</span>
|
1244
|
+
<span class="default">
|
1245
|
+
|
1246
|
+
</span>
|
1247
|
+
— <div class='inline'><p>the value of the hash key to find</p>
|
1248
|
+
</div>
|
1249
|
+
</li>
|
1250
|
+
|
1251
|
+
<li>
|
1252
|
+
<span class="name">:range_value</span>
|
1253
|
+
<span class="type">(<tt>Range</tt>)</span>
|
1254
|
+
<span class="default">
|
1255
|
+
|
1256
|
+
</span>
|
1257
|
+
— <div class='inline'><p>find the range key within this range</p>
|
1258
|
+
</div>
|
1259
|
+
</li>
|
1260
|
+
|
1261
|
+
<li>
|
1262
|
+
<span class="name">:range_greater_than</span>
|
1263
|
+
<span class="type">(<tt>Number</tt>)</span>
|
1264
|
+
<span class="default">
|
1265
|
+
|
1266
|
+
</span>
|
1267
|
+
— <div class='inline'><p>find range keys greater than this</p>
|
1268
|
+
</div>
|
1269
|
+
</li>
|
1270
|
+
|
1271
|
+
<li>
|
1272
|
+
<span class="name">:range_less_than</span>
|
1273
|
+
<span class="type">(<tt>Number</tt>)</span>
|
1274
|
+
<span class="default">
|
1275
|
+
|
1276
|
+
</span>
|
1277
|
+
— <div class='inline'><p>find range keys less than this</p>
|
1278
|
+
</div>
|
1279
|
+
</li>
|
1280
|
+
|
1281
|
+
<li>
|
1282
|
+
<span class="name">:range_gte</span>
|
1283
|
+
<span class="type">(<tt>Number</tt>)</span>
|
1284
|
+
<span class="default">
|
1285
|
+
|
1286
|
+
</span>
|
1287
|
+
— <div class='inline'><p>find range keys greater than or equal to this</p>
|
1288
|
+
</div>
|
1289
|
+
</li>
|
1290
|
+
|
1291
|
+
<li>
|
1292
|
+
<span class="name">:range_lte</span>
|
1293
|
+
<span class="type">(<tt>Number</tt>)</span>
|
1294
|
+
<span class="default">
|
1295
|
+
|
1296
|
+
</span>
|
1297
|
+
— <div class='inline'><p>find range keys less than or equal to this</p>
|
1298
|
+
</div>
|
1299
|
+
</li>
|
1300
|
+
|
1301
|
+
</ul>
|
1302
|
+
|
1303
|
+
|
1304
|
+
<h3>Returns:</h3>
|
1305
|
+
<ul class="return">
|
1306
|
+
|
1307
|
+
<li>
|
1308
|
+
|
1309
|
+
|
1310
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
1311
|
+
|
1312
|
+
|
1313
|
+
|
1314
|
+
—
|
1315
|
+
<div class='inline'><p>an array of all matching items</p>
|
1316
|
+
</div>
|
1317
|
+
|
1318
|
+
</li>
|
1319
|
+
|
1320
|
+
</ul>
|
1321
|
+
<h3>Since:</h3>
|
1322
|
+
<ul class="since">
|
1323
|
+
|
1324
|
+
<li>
|
1325
|
+
|
1326
|
+
|
1327
|
+
|
1328
|
+
|
1329
|
+
|
1330
|
+
<div class='inline'><p>0.2.0</p>
|
1331
|
+
</div>
|
1332
|
+
|
1333
|
+
</li>
|
1334
|
+
|
1335
|
+
</ul>
|
1336
|
+
|
1337
|
+
</div><table class="source_code">
|
1338
|
+
<tr>
|
1339
|
+
<td>
|
1340
|
+
<pre class="lines">
|
1341
|
+
|
1342
|
+
|
1343
|
+
140
|
1344
|
+
141
|
1345
|
+
142
|
1346
|
+
143
|
1347
|
+
144
|
1348
|
+
145
|
1349
|
+
146
|
1350
|
+
147
|
1351
|
+
148
|
1352
|
+
149
|
1353
|
+
150
|
1354
|
+
151
|
1355
|
+
152
|
1356
|
+
153
|
1357
|
+
154
|
1358
|
+
155
|
1359
|
+
156
|
1360
|
+
157
|
1361
|
+
158
|
1362
|
+
159
|
1363
|
+
160
|
1364
|
+
161
|
1365
|
+
162</pre>
|
1366
|
+
</td>
|
1367
|
+
<td>
|
1368
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter/local.rb', line 140</span>
|
1369
|
+
|
1370
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_query'>query</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
1371
|
+
<span class='id identifier rubyid_id'>id</span> <span class='op'>=</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span>
|
1372
|
+
<span class='id identifier rubyid_hash_key'>hash_key</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:hash_key</span><span class='rbracket'>]</span>
|
1373
|
+
<span class='id identifier rubyid_range_key'>range_key</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:range_key</span><span class='rbracket'>]</span>
|
1374
|
+
|
1375
|
+
<span class='id identifier rubyid_results'>results</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:range_value</span><span class='rbracket'>]</span>
|
1376
|
+
<span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_find_all'>find_all</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_hash_key'>hash_key</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='id identifier rubyid_id'>id</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_range_key'>range_key</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:range_value</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_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_range_key'>range_key</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='rbrace'>}</span>
|
1377
|
+
<span class='kw'>elsif</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:range_greater_than</span><span class='rbracket'>]</span>
|
1378
|
+
<span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_find_all'>find_all</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_hash_key'>hash_key</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='id identifier rubyid_id'>id</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_range_key'>range_key</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_range_key'>range_key</span><span class='rbracket'>]</span> <span class='op'>></span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:range_greater_than</span><span class='rbracket'>]</span><span class='rbrace'>}</span>
|
1379
|
+
<span class='kw'>elsif</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:range_less_than</span><span class='rbracket'>]</span>
|
1380
|
+
<span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_find_all'>find_all</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_hash_key'>hash_key</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='id identifier rubyid_id'>id</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_range_key'>range_key</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_range_key'>range_key</span><span class='rbracket'>]</span> <span class='op'><</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:range_less_than</span><span class='rbracket'>]</span><span class='rbrace'>}</span>
|
1381
|
+
<span class='kw'>elsif</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:range_gte</span><span class='rbracket'>]</span>
|
1382
|
+
<span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_find_all'>find_all</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_hash_key'>hash_key</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='id identifier rubyid_id'>id</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_range_key'>range_key</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_range_key'>range_key</span><span class='rbracket'>]</span> <span class='op'>>=</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:range_gte</span><span class='rbracket'>]</span><span class='rbrace'>}</span>
|
1383
|
+
<span class='kw'>elsif</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:range_lte</span><span class='rbracket'>]</span>
|
1384
|
+
<span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_find_all'>find_all</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_hash_key'>hash_key</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='id identifier rubyid_id'>id</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_range_key'>range_key</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_range_key'>range_key</span><span class='rbracket'>]</span> <span class='op'><=</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:range_lte</span><span class='rbracket'>]</span><span class='rbrace'>}</span>
|
1385
|
+
<span class='kw'>else</span>
|
1386
|
+
<span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_find_all'>find_all</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_hash_key'>hash_key</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='id identifier rubyid_id'>id</span><span class='rbrace'>}</span>
|
1387
|
+
<span class='kw'>end</span>
|
1388
|
+
|
1389
|
+
<span class='id identifier rubyid_results'>results</span> <span class='op'>=</span> <span class='id identifier rubyid_drop_till_start'>drop_till_start</span><span class='lparen'>(</span><span class='id identifier rubyid_results'>results</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:next_token</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_range_key'>range_key</span><span class='comma'>,</span> <span class='id identifier rubyid_hash_key'>hash_key</span><span class='rparen'>)</span>
|
1390
|
+
<span class='id identifier rubyid_results'>results</span> <span class='op'>=</span> <span class='id identifier rubyid_results'>results</span><span class='period'>.</span><span class='id identifier rubyid_take'>take</span><span class='lparen'>(</span><span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:limit</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:limit</span><span class='rbracket'>]</span>
|
1391
|
+
<span class='id identifier rubyid_results'>results</span>
|
1392
|
+
<span class='kw'>end</span></pre>
|
1393
|
+
</td>
|
1394
|
+
</tr>
|
1395
|
+
</table>
|
1396
|
+
</div>
|
1397
|
+
|
1398
|
+
<div class="method_details ">
|
1399
|
+
<p class="signature " id="reset_data-instance_method">
|
1400
|
+
|
1401
|
+
- (<tt>Object</tt>) <strong>reset_data</strong>
|
1402
|
+
|
1403
|
+
|
1404
|
+
|
1405
|
+
</p><div class="docstring">
|
1406
|
+
<div class="discussion">
|
1407
|
+
<p>A convenience method for testing that destroys all table data without destroying their structure.</p>
|
1408
|
+
|
1409
|
+
|
1410
|
+
</div>
|
1411
|
+
</div>
|
1412
|
+
<div class="tags">
|
1413
|
+
|
1414
|
+
<h3>Since:</h3>
|
1415
|
+
<ul class="since">
|
1416
|
+
|
1417
|
+
<li>
|
1418
|
+
|
1419
|
+
|
1420
|
+
|
1421
|
+
|
1422
|
+
|
1423
|
+
<div class='inline'><p>0.2.0</p>
|
1424
|
+
</div>
|
1425
|
+
|
1426
|
+
</li>
|
1427
|
+
|
1428
|
+
</ul>
|
1429
|
+
|
1430
|
+
</div><table class="source_code">
|
1431
|
+
<tr>
|
1432
|
+
<td>
|
1433
|
+
<pre class="lines">
|
1434
|
+
|
1435
|
+
|
1436
|
+
21
|
1437
|
+
22
|
1438
|
+
23</pre>
|
1439
|
+
</td>
|
1440
|
+
<td>
|
1441
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter/local.rb', line 21</span>
|
1442
|
+
|
1443
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_reset_data'>reset_data</span>
|
1444
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</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_v'>v</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rbrace'>}</span>
|
1445
|
+
<span class='kw'>end</span></pre>
|
1446
|
+
</td>
|
1447
|
+
</tr>
|
1448
|
+
</table>
|
1449
|
+
</div>
|
1450
|
+
|
1451
|
+
<div class="method_details ">
|
1452
|
+
<p class="signature " id="scan-instance_method">
|
1453
|
+
|
1454
|
+
- (<tt>Array</tt>) <strong>scan</strong>(table_name, scan_hash, opts = {})
|
1455
|
+
|
1456
|
+
|
1457
|
+
|
1458
|
+
</p><div class="docstring">
|
1459
|
+
<div class="discussion">
|
1460
|
+
<p>Scan the hash.</p>
|
1461
|
+
|
1462
|
+
|
1463
|
+
</div>
|
1464
|
+
</div>
|
1465
|
+
<div class="tags">
|
1466
|
+
<h3>Parameters:</h3>
|
1467
|
+
<ul class="param">
|
1468
|
+
|
1469
|
+
<li>
|
1470
|
+
|
1471
|
+
<span class='name'>table_name</span>
|
1472
|
+
|
1473
|
+
|
1474
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1475
|
+
|
1476
|
+
|
1477
|
+
|
1478
|
+
—
|
1479
|
+
<div class='inline'><p>the name of the table</p>
|
1480
|
+
</div>
|
1481
|
+
|
1482
|
+
</li>
|
1483
|
+
|
1484
|
+
<li>
|
1485
|
+
|
1486
|
+
<span class='name'>scan_hash</span>
|
1487
|
+
|
1488
|
+
|
1489
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1490
|
+
|
1491
|
+
|
1492
|
+
|
1493
|
+
—
|
1494
|
+
<div class='inline'><p>a hash of attributes: matching records will be returned by the scan</p>
|
1495
|
+
</div>
|
1496
|
+
|
1497
|
+
</li>
|
1498
|
+
|
1499
|
+
</ul>
|
1500
|
+
|
1501
|
+
<h3>Returns:</h3>
|
1502
|
+
<ul class="return">
|
1503
|
+
|
1504
|
+
<li>
|
1505
|
+
|
1506
|
+
|
1507
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
1508
|
+
|
1509
|
+
|
1510
|
+
|
1511
|
+
—
|
1512
|
+
<div class='inline'><p>an array of all matching items</p>
|
1513
|
+
</div>
|
1514
|
+
|
1515
|
+
</li>
|
1516
|
+
|
1517
|
+
</ul>
|
1518
|
+
<h3>Since:</h3>
|
1519
|
+
<ul class="since">
|
1520
|
+
|
1521
|
+
<li>
|
1522
|
+
|
1523
|
+
|
1524
|
+
|
1525
|
+
|
1526
|
+
|
1527
|
+
<div class='inline'><p>0.2.0</p>
|
1528
|
+
</div>
|
1529
|
+
|
1530
|
+
</li>
|
1531
|
+
|
1532
|
+
</ul>
|
1533
|
+
|
1534
|
+
</div><table class="source_code">
|
1535
|
+
<tr>
|
1536
|
+
<td>
|
1537
|
+
<pre class="lines">
|
1538
|
+
|
1539
|
+
|
1540
|
+
172
|
1541
|
+
173
|
1542
|
+
174
|
1543
|
+
175
|
1544
|
+
176
|
1545
|
+
177
|
1546
|
+
178</pre>
|
1547
|
+
</td>
|
1548
|
+
<td>
|
1549
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter/local.rb', line 172</span>
|
1550
|
+
|
1551
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_scan'>scan</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_scan_hash'>scan_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
1552
|
+
<span class='kw'>return</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
1553
|
+
<span class='id identifier rubyid_results'>results</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_d'>d</span><span class='op'>|</span> <span class='id identifier rubyid_scan_hash'>scan_hash</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_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='op'>!</span><span class='id identifier rubyid_d'>d</span><span class='lbracket'>[</span><span class='id identifier rubyid_k'>k</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='id identifier rubyid_d'>d</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><span class='rbrace'>}</span>
|
1554
|
+
<span class='id identifier rubyid_results'>results</span> <span class='op'>=</span> <span class='id identifier rubyid_drop_till_start'>drop_till_start</span><span class='lparen'>(</span><span class='id identifier rubyid_results'>results</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:next_token</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:range_key</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:hash_key</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
1555
|
+
<span class='id identifier rubyid_results'>results</span> <span class='op'>=</span> <span class='id identifier rubyid_results'>results</span><span class='period'>.</span><span class='id identifier rubyid_take'>take</span><span class='lparen'>(</span><span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:limit</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:limit</span><span class='rbracket'>]</span>
|
1556
|
+
<span class='id identifier rubyid_results'>results</span>
|
1557
|
+
<span class='kw'>end</span></pre>
|
1558
|
+
</td>
|
1559
|
+
</tr>
|
1560
|
+
</table>
|
1561
|
+
</div>
|
1562
|
+
|
1563
|
+
</div>
|
1564
|
+
|
1565
|
+
</div>
|
1566
|
+
|
1567
|
+
<div id="footer">
|
1568
|
+
Generated on Thu Apr 26 01:26:25 2012 by
|
1569
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1570
|
+
0.7.5 (ruby-1.9.3).
|
1571
|
+
</div>
|
1572
|
+
|
1573
|
+
</body>
|
1574
|
+
</html>
|