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,309 @@
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::Fields::ClassMethods
8
+
9
+ &mdash; Documentation by YARD 0.7.5
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ relpath = '../..';
19
+ if (relpath != '') relpath += '/';
20
+ </script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
25
+
26
+
27
+ </head>
28
+ <body>
29
+ <script type="text/javascript" charset="utf-8">
30
+ if (window.top.frames.main) document.body.className = 'frames';
31
+ </script>
32
+
33
+ <div id="header">
34
+ <div id="menu">
35
+
36
+ <a href="../../_index.html">Index (C)</a> &raquo;
37
+ <span class='title'><span class='object_link'><a href="../../Dynamoid.html" title="Dynamoid (module)">Dynamoid</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Fields.html" title="Dynamoid::Fields (module)">Fields</a></span></span>
38
+ &raquo;
39
+ <span class="title">ClassMethods</span>
40
+
41
+
42
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
43
+ </div>
44
+
45
+ <div id="search">
46
+
47
+ <a id="class_list_link" href="#">Class List</a>
48
+
49
+ <a id="method_list_link" href="#">Method List</a>
50
+
51
+ <a id="file_list_link" href="#">File List</a>
52
+
53
+ </div>
54
+ <div class="clear"></div>
55
+ </div>
56
+
57
+ <iframe id="search_frame"></iframe>
58
+
59
+ <div id="content"><h1>Module: Dynamoid::Fields::ClassMethods
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+ <dt class="r1 last">Defined in:</dt>
75
+ <dd class="r1 last">lib/dynamoid/fields.rb</dd>
76
+
77
+ </dl>
78
+ <div class="clear"></div>
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+ <h2>
89
+ Instance Method Summary
90
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
91
+ </h2>
92
+
93
+ <ul class="summary">
94
+
95
+ <li class="public ">
96
+ <span class="summary_signature">
97
+
98
+ <a href="#field-instance_method" title="#field (instance method)">- (Object) <strong>field</strong>(name, type = :string, options = {}) </a>
99
+
100
+
101
+
102
+ </span>
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ <span class="summary_desc"><div class='inline'><p>Specify a field for a document.</p>
112
+ </div></span>
113
+
114
+ </li>
115
+
116
+
117
+ <li class="public ">
118
+ <span class="summary_signature">
119
+
120
+ <a href="#range-instance_method" title="#range (instance method)">- (Object) <strong>range</strong>(name, type = :string) </a>
121
+
122
+
123
+
124
+ </span>
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ <span class="summary_desc"><div class='inline'></div></span>
134
+
135
+ </li>
136
+
137
+
138
+ </ul>
139
+
140
+
141
+
142
+
143
+ <div id="instance_method_details" class="method_details_list">
144
+ <h2>Instance Method Details</h2>
145
+
146
+
147
+ <div class="method_details first">
148
+ <p class="signature first" id="field-instance_method">
149
+
150
+ - (<tt>Object</tt>) <strong>field</strong>(name, type = :string, options = {})
151
+
152
+
153
+
154
+ </p><div class="docstring">
155
+ <div class="discussion">
156
+ <p>Specify a field for a document. Its type determines how it is coerced when read in and out of the datastore:
157
+ default is string, but you can also specify :integer, :float, :set, :array, :datetime, and :serialized.</p>
158
+
159
+
160
+ </div>
161
+ </div>
162
+ <div class="tags">
163
+ <h3>Parameters:</h3>
164
+ <ul class="param">
165
+
166
+ <li>
167
+
168
+ <span class='name'>name</span>
169
+
170
+
171
+ <span class='type'>(<tt>Symbol</tt>)</span>
172
+
173
+
174
+
175
+ &mdash;
176
+ <div class='inline'><p>the name of the field</p>
177
+ </div>
178
+
179
+ </li>
180
+
181
+ <li>
182
+
183
+ <span class='name'>type</span>
184
+
185
+
186
+ <span class='type'>(<tt>Symbol</tt>)</span>
187
+
188
+
189
+ <em class="default">(defaults to: <tt>:string</tt>)</em>
190
+
191
+
192
+ &mdash;
193
+ <div class='inline'><p>the type of the field (one of :integer, :float, :set, :array, :datetime, or :serialized)</p>
194
+ </div>
195
+
196
+ </li>
197
+
198
+ <li>
199
+
200
+ <span class='name'>options</span>
201
+
202
+
203
+ <span class='type'>(<tt>Hash</tt>)</span>
204
+
205
+
206
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
207
+
208
+
209
+ &mdash;
210
+ <div class='inline'><p>any additional options for the field</p>
211
+ </div>
212
+
213
+ </li>
214
+
215
+ </ul>
216
+
217
+ <h3>Since:</h3>
218
+ <ul class="since">
219
+
220
+ <li>
221
+
222
+
223
+
224
+
225
+
226
+ <div class='inline'><p>0.2.0</p>
227
+ </div>
228
+
229
+ </li>
230
+
231
+ </ul>
232
+
233
+ </div><table class="source_code">
234
+ <tr>
235
+ <td>
236
+ <pre class="lines">
237
+
238
+
239
+ 30
240
+ 31
241
+ 32
242
+ 33
243
+ 34
244
+ 35
245
+ 36
246
+ 37
247
+ 38
248
+ 39</pre>
249
+ </td>
250
+ <td>
251
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/fields.rb', line 30</span>
252
+
253
+ <span class='kw'>def</span> <span class='id identifier rubyid_field'>field</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='symbol'>:string</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>
254
+ <span class='id identifier rubyid_named'>named</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
255
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_attributes'>attributes</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='symbol'>:type</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_type'>type</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
256
+
257
+ <span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='id identifier rubyid_named'>named</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_read_attribute'>read_attribute</span><span class='lparen'>(</span><span class='id identifier rubyid_named'>named</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
258
+ <span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_named'>named</span><span class='rbrace'>}</span><span class='tstring_content'>?</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>!</span><span class='id identifier rubyid_read_attribute'>read_attribute</span><span class='lparen'>(</span><span class='id identifier rubyid_named'>named</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='rbrace'>}</span>
259
+ <span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_named'>named</span><span class='rbrace'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_value'>value</span><span class='op'>|</span> <span class='id identifier rubyid_write_attribute'>write_attribute</span><span class='lparen'>(</span><span class='id identifier rubyid_named'>named</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
260
+
261
+ <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:define_attribute_method</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_define_attribute_method'>define_attribute_method</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_define_attribute_methods'>define_attribute_methods</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='rparen'>)</span>
262
+ <span class='kw'>end</span></pre>
263
+ </td>
264
+ </tr>
265
+ </table>
266
+ </div>
267
+
268
+ <div class="method_details ">
269
+ <p class="signature " id="range-instance_method">
270
+
271
+ - (<tt>Object</tt>) <strong>range</strong>(name, type = :string)
272
+
273
+
274
+
275
+ </p><table class="source_code">
276
+ <tr>
277
+ <td>
278
+ <pre class="lines">
279
+
280
+
281
+ 41
282
+ 42
283
+ 43
284
+ 44</pre>
285
+ </td>
286
+ <td>
287
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/fields.rb', line 41</span>
288
+
289
+ <span class='kw'>def</span> <span class='id identifier rubyid_range'>range</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='symbol'>:string</span><span class='rparen'>)</span>
290
+ <span class='id identifier rubyid_field'>field</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='rparen'>)</span>
291
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_range_key'>range_key</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span>
292
+ <span class='kw'>end</span></pre>
293
+ </td>
294
+ </tr>
295
+ </table>
296
+ </div>
297
+
298
+ </div>
299
+
300
+ </div>
301
+
302
+ <div id="footer">
303
+ Generated on Thu Apr 26 01:26:24 2012 by
304
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
305
+ 0.7.5 (ruby-1.9.3).
306
+ </div>
307
+
308
+ </body>
309
+ </html>
@@ -0,0 +1,128 @@
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::Finders
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 (F)</a> &raquo;
37
+ <span class='title'><span class='object_link'><a href="../Dynamoid.html" title="Dynamoid (module)">Dynamoid</a></span></span>
38
+ &raquo;
39
+ <span class="title">Finders</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::Finders
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+
68
+
69
+ <dt class="r1">Extended by:</dt>
70
+ <dd class="r1">ActiveSupport::Concern</dd>
71
+
72
+
73
+
74
+
75
+
76
+
77
+ <dt class="r2">Included in:</dt>
78
+ <dd class="r2"><span class='object_link'><a href="Components.html" title="Dynamoid::Components (module)">Components</a></span></dd>
79
+
80
+
81
+
82
+ <dt class="r1 last">Defined in:</dt>
83
+ <dd class="r1 last">lib/dynamoid/finders.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 module defines the finder methods that hang off the document at the
91
+ class level, like find, find_by_id, and the method_missing style finders.</p>
92
+
93
+
94
+ </div>
95
+ </div>
96
+ <div class="tags">
97
+
98
+
99
+ </div><h2>Defined Under Namespace</h2>
100
+ <p class="children">
101
+
102
+
103
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Finders/ClassMethods.html" title="Dynamoid::Finders::ClassMethods (module)">ClassMethods</a></span>
104
+
105
+
106
+
107
+
108
+ </p>
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+ </div>
120
+
121
+ <div id="footer">
122
+ Generated on Thu Apr 26 01:26:24 2012 by
123
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
124
+ 0.7.5 (ruby-1.9.3).
125
+ </div>
126
+
127
+ </body>
128
+ </html>
@@ -0,0 +1,516 @@
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::Finders::ClassMethods
8
+
9
+ &mdash; Documentation by YARD 0.7.5
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ relpath = '../..';
19
+ if (relpath != '') relpath += '/';
20
+ </script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
25
+
26
+
27
+ </head>
28
+ <body>
29
+ <script type="text/javascript" charset="utf-8">
30
+ if (window.top.frames.main) document.body.className = 'frames';
31
+ </script>
32
+
33
+ <div id="header">
34
+ <div id="menu">
35
+
36
+ <a href="../../_index.html">Index (C)</a> &raquo;
37
+ <span class='title'><span class='object_link'><a href="../../Dynamoid.html" title="Dynamoid (module)">Dynamoid</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Finders.html" title="Dynamoid::Finders (module)">Finders</a></span></span>
38
+ &raquo;
39
+ <span class="title">ClassMethods</span>
40
+
41
+
42
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
43
+ </div>
44
+
45
+ <div id="search">
46
+
47
+ <a id="class_list_link" href="#">Class List</a>
48
+
49
+ <a id="method_list_link" href="#">Method List</a>
50
+
51
+ <a id="file_list_link" href="#">File List</a>
52
+
53
+ </div>
54
+ <div class="clear"></div>
55
+ </div>
56
+
57
+ <iframe id="search_frame"></iframe>
58
+
59
+ <div id="content"><h1>Module: Dynamoid::Finders::ClassMethods
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+ <dt class="r1 last">Defined in:</dt>
75
+ <dd class="r1 last">lib/dynamoid/finders.rb</dd>
76
+
77
+ </dl>
78
+ <div class="clear"></div>
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+ <h2>
89
+ Instance Method Summary
90
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
91
+ </h2>
92
+
93
+ <ul class="summary">
94
+
95
+ <li class="public ">
96
+ <span class="summary_signature">
97
+
98
+ <a href="#find-instance_method" title="#find (instance method)">- (Dynamoid::Document) <strong>find</strong>(*ids) </a>
99
+
100
+
101
+
102
+ </span>
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ <span class="summary_desc"><div class='inline'><p>Find one or many objects, specified by one id or an array of ids.</p>
112
+ </div></span>
113
+
114
+ </li>
115
+
116
+
117
+ <li class="public ">
118
+ <span class="summary_signature">
119
+
120
+ <a href="#find_by_id-instance_method" title="#find_by_id (instance method)">- (Dynamoid::Document) <strong>find_by_id</strong>(id, options = {}) </a>
121
+
122
+
123
+
124
+ </span>
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ <span class="summary_desc"><div class='inline'><p>Find one object directly by id.</p>
134
+ </div></span>
135
+
136
+ </li>
137
+
138
+
139
+ <li class="public ">
140
+ <span class="summary_signature">
141
+
142
+ <a href="#method_missing-instance_method" title="#method_missing (instance method)">- (Dynamoid::Document/Array) <strong>method_missing</strong>(method, *args) </a>
143
+
144
+
145
+
146
+ </span>
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+ <span class="summary_desc"><div class='inline'><p>Find using exciting method_missing finders attributes.</p>
156
+ </div></span>
157
+
158
+ </li>
159
+
160
+
161
+ </ul>
162
+
163
+
164
+ <div id="method_missing_details" class="method_details_list">
165
+ <h2>Dynamic Method Handling</h2>
166
+ <p class="notice this">
167
+ This class handles dynamic methods through the <tt>method_missing</tt> method
168
+
169
+ </p>
170
+
171
+ <div class="method_details first">
172
+ <p class="signature first" id="method_missing-instance_method">
173
+
174
+ - (<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span>/Array</tt>) <strong>method_missing</strong>(method, *args)
175
+
176
+
177
+
178
+ </p><div class="docstring">
179
+ <div class="discussion">
180
+ <p>Find using exciting method_missing finders attributes. Uses criteria chains under the hood to accomplish this neatness.</p>
181
+
182
+
183
+ </div>
184
+ </div>
185
+ <div class="tags">
186
+
187
+ <div class="examples">
188
+ <h3>Examples:</h3>
189
+
190
+ <h4><div class='inline'><p>find a user by a first name</p>
191
+ </div></h4>
192
+ <pre class="example code"><span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_find_by_first_name'>find_by_first_name</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Josh</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span></pre>
193
+
194
+ <h4><div class='inline'><p>find all users by first and last name</p>
195
+ </div></h4>
196
+ <pre class="example code"><span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_find_all_by_first_name_and_last_name'>find_all_by_first_name_and_last_name</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Josh</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Symonds</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span></pre>
197
+
198
+ </div>
199
+
200
+ <h3>Returns:</h3>
201
+ <ul class="return">
202
+
203
+ <li>
204
+
205
+
206
+ <span class='type'>(<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span>/Array</tt>)</span>
207
+
208
+
209
+
210
+ &mdash;
211
+ <div class='inline'><p>the found object, or an array of found objects if all was somewhere in the method</p>
212
+ </div>
213
+
214
+ </li>
215
+
216
+ </ul>
217
+ <h3>Since:</h3>
218
+ <ul class="since">
219
+
220
+ <li>
221
+
222
+
223
+
224
+
225
+
226
+ <div class='inline'><p>0.2.0</p>
227
+ </div>
228
+
229
+ </li>
230
+
231
+ </ul>
232
+
233
+ </div><table class="source_code">
234
+ <tr>
235
+ <td>
236
+ <pre class="lines">
237
+
238
+
239
+ 63
240
+ 64
241
+ 65
242
+ 66
243
+ 67
244
+ 68
245
+ 69
246
+ 70
247
+ 71
248
+ 72
249
+ 73
250
+ 74
251
+ 75
252
+ 76
253
+ 77
254
+ 78
255
+ 79</pre>
256
+ </td>
257
+ <td>
258
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/finders.rb', line 63</span>
259
+
260
+ <span class='kw'>def</span> <span class='id identifier rubyid_method_missing'>method_missing</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
261
+ <span class='kw'>if</span> <span class='id identifier rubyid_method'>method</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>find</span><span class='regexp_end'>/</span></span>
262
+ <span class='id identifier rubyid_finder'>finder</span> <span class='op'>=</span> <span class='id identifier rubyid_method'>method</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>_by_</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
263
+ <span class='id identifier rubyid_attributes'>attributes</span> <span class='op'>=</span> <span class='id identifier rubyid_method'>method</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>_by_</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</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>
264
+
265
+ <span class='id identifier rubyid_chain'>chain</span> <span class='op'>=</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Criteria</span><span class='op'>::</span><span class='const'>Chain</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
266
+ <span class='id identifier rubyid_chain'>chain</span><span class='period'>.</span><span class='id identifier rubyid_query'>query</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='period'>.</span><span class='id identifier rubyid_tap'>tap</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_h'>h</span><span class='op'>|</span> <span class='id identifier rubyid_attributes'>attributes</span><span class='period'>.</span><span class='id identifier rubyid_each_with_index'>each_with_index</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_attr'>attr</span><span class='comma'>,</span> <span class='id identifier rubyid_index'>index</span><span class='op'>|</span> <span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_attr'>attr</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='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='id identifier rubyid_index'>index</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='rbrace'>}</span>
267
+
268
+ <span class='kw'>if</span> <span class='id identifier rubyid_finder'>finder</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>all</span><span class='regexp_end'>/</span></span>
269
+ <span class='kw'>return</span> <span class='id identifier rubyid_chain'>chain</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span>
270
+ <span class='kw'>else</span>
271
+ <span class='kw'>return</span> <span class='id identifier rubyid_chain'>chain</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
272
+ <span class='kw'>end</span>
273
+ <span class='kw'>else</span>
274
+ <span class='kw'>super</span>
275
+ <span class='kw'>end</span>
276
+ <span class='kw'>end</span></pre>
277
+ </td>
278
+ </tr>
279
+ </table>
280
+ </div>
281
+
282
+ </div>
283
+
284
+
285
+ <div id="instance_method_details" class="method_details_list">
286
+ <h2>Instance Method Details</h2>
287
+
288
+
289
+ <div class="method_details first">
290
+ <p class="signature first" id="find-instance_method">
291
+
292
+ - (<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>) <strong>find</strong>(*ids)
293
+
294
+
295
+
296
+ </p><div class="docstring">
297
+ <div class="discussion">
298
+ <p>Find one or many objects, specified by one id or an array of ids.</p>
299
+
300
+
301
+ </div>
302
+ </div>
303
+ <div class="tags">
304
+ <h3>Parameters:</h3>
305
+ <ul class="param">
306
+
307
+ <li>
308
+
309
+ <span class='name'>*id</span>
310
+
311
+
312
+ <span class='type'>(<tt>Array/String</tt>)</span>
313
+
314
+
315
+
316
+ &mdash;
317
+ <div class='inline'><p>an array of ids or one single id</p>
318
+ </div>
319
+
320
+ </li>
321
+
322
+ </ul>
323
+
324
+ <h3>Returns:</h3>
325
+ <ul class="return">
326
+
327
+ <li>
328
+
329
+
330
+ <span class='type'>(<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>)</span>
331
+
332
+
333
+
334
+ &mdash;
335
+ <div class='inline'><p>one object or an array of objects, depending on whether the input was an array or not</p>
336
+ </div>
337
+
338
+ </li>
339
+
340
+ </ul>
341
+ <h3>Since:</h3>
342
+ <ul class="since">
343
+
344
+ <li>
345
+
346
+
347
+
348
+
349
+
350
+ <div class='inline'><p>0.2.0</p>
351
+ </div>
352
+
353
+ </li>
354
+
355
+ </ul>
356
+
357
+ </div><table class="source_code">
358
+ <tr>
359
+ <td>
360
+ <pre class="lines">
361
+
362
+
363
+ 18
364
+ 19
365
+ 20
366
+ 21
367
+ 22
368
+ 23
369
+ 24
370
+ 25
371
+ 26
372
+ 27
373
+ 28
374
+ 29
375
+ 30
376
+ 31
377
+ 32
378
+ 33</pre>
379
+ </td>
380
+ <td>
381
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/finders.rb', line 18</span>
382
+
383
+ <span class='kw'>def</span> <span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_ids'>ids</span><span class='rparen'>)</span>
384
+
385
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_ids'>ids</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Hash</span>
386
+ <span class='id identifier rubyid_ids'>ids</span><span class='period'>.</span><span class='id identifier rubyid_slice!'>slice!</span><span class='lparen'>(</span><span class='op'>-</span><span class='int'>1</span><span class='rparen'>)</span>
387
+ <span class='kw'>else</span>
388
+ <span class='lbrace'>{</span><span class='rbrace'>}</span>
389
+ <span class='kw'>end</span>
390
+
391
+ <span class='id identifier rubyid_ids'>ids</span> <span class='op'>=</span> <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_ids'>ids</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><span class='rparen'>)</span>
392
+ <span class='kw'>if</span> <span class='id identifier rubyid_ids'>ids</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>==</span> <span class='int'>1</span>
393
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_find_by_id'>find_by_id</span><span class='lparen'>(</span><span class='id identifier rubyid_ids'>ids</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
394
+ <span class='kw'>else</span>
395
+ <span class='id identifier rubyid_items'>items</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_ids'>ids</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
396
+ <span class='id identifier rubyid_items'>items</span><span class='lbracket'>[</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</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_i'>i</span><span class='op'>|</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_build'>build</span><span class='lparen'>(</span><span class='id identifier rubyid_i'>i</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_tap'>tap</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_o'>o</span><span class='op'>|</span> <span class='id identifier rubyid_o'>o</span><span class='period'>.</span><span class='id identifier rubyid_new_record'>new_record</span> <span class='op'>=</span> <span class='kw'>false</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
397
+ <span class='kw'>end</span>
398
+ <span class='kw'>end</span></pre>
399
+ </td>
400
+ </tr>
401
+ </table>
402
+ </div>
403
+
404
+ <div class="method_details ">
405
+ <p class="signature " id="find_by_id-instance_method">
406
+
407
+ - (<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>) <strong>find_by_id</strong>(id, options = {})
408
+
409
+
410
+
411
+ </p><div class="docstring">
412
+ <div class="discussion">
413
+ <p>Find one object directly by id.</p>
414
+
415
+
416
+ </div>
417
+ </div>
418
+ <div class="tags">
419
+ <h3>Parameters:</h3>
420
+ <ul class="param">
421
+
422
+ <li>
423
+
424
+ <span class='name'>id</span>
425
+
426
+
427
+ <span class='type'>(<tt>String</tt>)</span>
428
+
429
+
430
+
431
+ &mdash;
432
+ <div class='inline'><p>the id of the object to find</p>
433
+ </div>
434
+
435
+ </li>
436
+
437
+ </ul>
438
+
439
+ <h3>Returns:</h3>
440
+ <ul class="return">
441
+
442
+ <li>
443
+
444
+
445
+ <span class='type'>(<tt><span class='object_link'><a href="../Document.html" title="Dynamoid::Document (module)">Dynamoid::Document</a></span></tt>)</span>
446
+
447
+
448
+
449
+ &mdash;
450
+ <div class='inline'><p>the found object, or nil if nothing was found</p>
451
+ </div>
452
+
453
+ </li>
454
+
455
+ </ul>
456
+ <h3>Since:</h3>
457
+ <ul class="since">
458
+
459
+ <li>
460
+
461
+
462
+
463
+
464
+
465
+ <div class='inline'><p>0.2.0</p>
466
+ </div>
467
+
468
+ </li>
469
+
470
+ </ul>
471
+
472
+ </div><table class="source_code">
473
+ <tr>
474
+ <td>
475
+ <pre class="lines">
476
+
477
+
478
+ 42
479
+ 43
480
+ 44
481
+ 45
482
+ 46
483
+ 47
484
+ 48
485
+ 49
486
+ 50</pre>
487
+ </td>
488
+ <td>
489
+ <pre class="code"><span class="info file"># File 'lib/dynamoid/finders.rb', line 42</span>
490
+
491
+ <span class='kw'>def</span> <span class='id identifier rubyid_find_by_id'>find_by_id</span><span class='lparen'>(</span><span class='id identifier rubyid_id'>id</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>
492
+ <span class='kw'>if</span> <span class='id identifier rubyid_item'>item</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_id'>id</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
493
+ <span class='id identifier rubyid_obj'>obj</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_item'>item</span><span class='rparen'>)</span>
494
+ <span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid_new_record'>new_record</span> <span class='op'>=</span> <span class='kw'>false</span>
495
+ <span class='kw'>return</span> <span class='id identifier rubyid_obj'>obj</span>
496
+ <span class='kw'>else</span>
497
+ <span class='kw'>return</span> <span class='kw'>nil</span>
498
+ <span class='kw'>end</span>
499
+ <span class='kw'>end</span></pre>
500
+ </td>
501
+ </tr>
502
+ </table>
503
+ </div>
504
+
505
+ </div>
506
+
507
+ </div>
508
+
509
+ <div id="footer">
510
+ Generated on Thu Apr 26 01:26:24 2012 by
511
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
512
+ 0.7.5 (ruby-1.9.3).
513
+ </div>
514
+
515
+ </body>
516
+ </html>