inquery 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,26 +1,17 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
3
-
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
1
+ <!DOCTYPE html>
2
+ <html>
5
3
  <head>
6
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
- <title>Documentation by YARD 0.8.7.6</title>
4
+ <meta charset="utf-8">
5
+ <title>Documentation by YARD 0.9.9</title>
8
6
  </head>
9
7
  <script type="text/javascript" charset="utf-8">
10
- window.onload = function() {
11
8
  var match = unescape(window.location.hash).match(/^#!(.+)/);
12
9
  var name = match ? match[1] : 'index.html';
13
10
  name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
14
- document.writeln('<frameset cols="20%,*">' +
15
- '<frame name="list" src="class_list.html" />' +
16
- '<frame name="main" src="' + escape(name) + '" />' +
17
- '</frameset>');
18
- }
11
+ window.top.location = name;
19
12
  </script>
20
13
  <noscript>
21
- <frameset cols="20%,*">
22
- <frame name="list" src="class_list.html" />
23
- <frame name="main" src="index.html" />
24
- </frameset>
14
+ <h1>Oops!</h1>
15
+ <h2>YARD requires JavaScript!</h2>
25
16
  </noscript>
26
17
  </html>
@@ -1,12 +1,12 @@
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">
1
+ <!DOCTYPE html>
2
+ <html>
4
3
  <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>
7
7
  File: README
8
8
 
9
- &mdash; Documentation by YARD 0.8.7.6
9
+ &mdash; Documentation by YARD 0.9.9
10
10
 
11
11
  </title>
12
12
 
@@ -15,9 +15,8 @@
15
15
  <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
16
 
17
17
  <script type="text/javascript" charset="utf-8">
18
- hasFrames = window.top.frames.main ? true : false;
18
+ pathId = "README";
19
19
  relpath = '';
20
- framesUrl = "frames.html#!file.README.html";
21
20
  </script>
22
21
 
23
22
 
@@ -28,59 +27,59 @@
28
27
 
29
28
  </head>
30
29
  <body>
31
- <div id="header">
32
- <div id="menu">
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
33
38
 
34
39
  <a href="_index.html">Index</a> &raquo;
35
40
  <span class="title">File: README</span>
36
41
 
37
-
38
- <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
39
42
  </div>
40
43
 
41
- <div id="search">
44
+ <div id="search">
42
45
 
43
46
  <a class="full_list_link" id="class_list_link"
44
47
  href="class_list.html">
45
- Class List
46
- </a>
47
-
48
- <a class="full_list_link" id="method_list_link"
49
- href="method_list.html">
50
- Method List
51
- </a>
52
-
53
- <a class="full_list_link" id="file_list_link"
54
- href="file_list.html">
55
- File List
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
56
54
  </a>
57
55
 
58
56
  </div>
59
- <div class="clear"></div>
60
- </div>
57
+ <div class="clear"></div>
58
+ </div>
61
59
 
62
- <iframe id="search_frame"></iframe>
60
+ <div id="content"><div id='filecontents'><p><a href="https://travis-ci.org/sitrox/inquery"><img src="https://travis-ci.org/sitrox/inquery.svg?branch=master" alt="Build Status"></a>
61
+ <a href="https://badge.fury.io/rb/inquery"><img src="https://badge.fury.io/rb/inquery.svg" alt="Gem Version"></a></p>
63
62
 
64
- <div id="content"><div id='filecontents'>
65
- <h1 id="label-Inquery">Inquery</h1>
63
+ <h1>Inquery</h1>
66
64
 
67
65
  <p>A skeleton that allows extracting queries into atomic, reusable classes.</p>
68
66
 
69
- <h2 id="label-Installation">Installation</h2>
67
+ <h2>Installation</h2>
70
68
 
71
69
  <p>To install the <strong>Inquery</strong> gem:</p>
72
70
 
73
- <pre class="code ruby"><code class="ruby">$ gem install inquery</code></pre>
71
+ <pre class="code sh"><code class="sh">$ gem install inquery
72
+ </code></pre>
74
73
 
75
- <p>To install it using <code>bundler</code> (recommended for any application),
76
- add it to your <code>Gemfile</code>:</p>
74
+ <p>To install it using <code>bundler</code> (recommended for any application), add it
75
+ to your <code>Gemfile</code>:</p>
77
76
 
78
77
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>inquery</span><span class='tstring_end'>&#39;</span></span>
79
78
  </code></pre>
80
79
 
81
- <h2 id="label-Basic+usage">Basic usage</h2>
80
+ <h2>Basic usage</h2>
82
81
 
83
- <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>FetchUsersWithACar</span> <span class='op'>&lt;</span> <span class='const'>Inquery</span><span class='op'>::</span><span class='const'>Query</span>
82
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>FetchUsersWithACar</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="Inquery.html" title="Inquery (module)">Inquery</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Query</a></span></span>
84
83
  <span class='id identifier rubyid_schema'>schema</span><span class='lparen'>(</span>
85
84
  <span class='label'>color:</span> <span class='symbol'>:symbol</span>
86
85
  <span class='rparen'>)</span>
@@ -94,21 +93,21 @@ add it to your <code>Gemfile</code>:</p>
94
93
  <span class='comment'># =&gt; [&lt;User id: 1 ...]
95
94
  </span></code></pre>
96
95
 
97
- <p>Inquery offers its functionality trough two query base classes:
98
- <span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Inquery::Query</a></span> and <span class='object_link'><a href="Inquery/Query/Chainable.html" title="Inquery::Query::Chainable (class)">Inquery::Query::Chainable</a></span>. See the following
99
- sections for detailed explanations.</p>
96
+ <p>Inquery offers its functionality trough two query base classes: <span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Inquery::Query</a></span>
97
+ and <span class='object_link'><a href="Inquery/Query/Chainable.html" title="Inquery::Query::Chainable (class)">Inquery::Query::Chainable</a></span>. See the following sections for detailed
98
+ explanations.</p>
100
99
 
101
- <h2 id="label-Basic+queries">Basic queries</h2>
100
+ <h2>Basic queries</h2>
102
101
 
103
- <p>Basic queries inherit from <span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Inquery::Query</a></span>. They receive an optional set
104
- of parameters and commonly return a relation / AR result. An optional
105
- <code>process</code> method lets you perform additional result processing
106
- steps if needed (i.e. converting the result to a hash or similar).</p>
102
+ <p>Basic queries inherit from <span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Inquery::Query</a></span>. They receive an optional set of
103
+ parameters and commonly return a relation / AR result. An optional <code>process</code>
104
+ method lets you perform additional result processing steps if needed (i.e.
105
+ converting the result to a hash or similar).</p>
107
106
 
108
107
  <p>For this basic functionality, inherit from <span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Inquery::Query</a></span> and overwrite
109
108
  the <code>call</code> and optionally the <code>process</code> method:</p>
110
109
 
111
- <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>FetchRedCarsAsJson</span>
110
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>FetchRedCarsAsJson</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="Inquery.html" title="Inquery (module)">Inquery</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Query</a></span></span>
112
111
  <span class='comment'># The `call` method must be overwritten for every query. It is usually called
113
112
  </span> <span class='comment'># via `run`.
114
113
  </span> <span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
@@ -139,17 +138,15 @@ the <code>call</code> and optionally the <code>process</code> method:</p>
139
138
  </span><span class='const'>FetchRedCarsAsJson</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
140
139
  </code></pre>
141
140
 
142
- <p>Note that it&#39;s perfectly fine for some queries to return
143
- <code>nil</code>, i.e. if they&#39;re writing queries that don&#39;t fetch
144
- any results.</p>
141
+ <p>Note that it&#39;s perfectly fine for some queries to return <code>nil</code>, i.e. if they&#39;re
142
+ writing queries that don&#39;t fetch any results.</p>
145
143
 
146
- <h2 id="label-Chainable+queries">Chainable queries</h2>
144
+ <h2>Chainable queries</h2>
147
145
 
148
- <p>Chainable queries are queries that input and output an Active Record
149
- relation. You can access the given relation using the method
150
- <code>relation</code>:</p>
146
+ <p>Chainable queries are queries that input and output an Active Record relation.
147
+ You can access the given relation using the method <code>relation</code>:</p>
151
148
 
152
- <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>Queries</span><span class='op'>::</span><span class='const'>User</span><span class='op'>::</span><span class='const'>FetchActive</span> <span class='op'>&lt;</span> <span class='const'>Inquery</span><span class='op'>::</span><span class='const'>Query</span><span class='op'>::</span><span class='const'>Chainable</span>
149
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>Queries</span><span class='op'>::</span><span class='const'>User</span><span class='op'>::</span><span class='const'>FetchActive</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="Inquery.html" title="Inquery (module)">Inquery</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Query</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query/Chainable.html" title="Inquery::Query::Chainable (class)">Chainable</a></span></span>
153
150
  <span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
154
151
  <span class='id identifier rubyid_relation'>relation</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='label'>active:</span> <span class='int'>1</span><span class='rparen'>)</span>
155
152
  <span class='kw'>end</span>
@@ -157,15 +154,15 @@ relation. You can access the given relation using the method
157
154
  </code></pre>
158
155
 
159
156
  <p>Input and output relations may or may not be of the same AR class (i.e. you
160
- could pass a relation of <code>Group</code>s and receive back a relation of
161
- corresponding <code>User</code>s).</p>
157
+ could pass a relation of <code>Group</code>s and receive back a relation of corresponding
158
+ <code>User</code>s).</p>
162
159
 
163
- <h3 id="label-Relation+validation">Relation validation</h3>
160
+ <h3>Relation validation</h3>
164
161
 
165
162
  <p>Chainable queries allow you to further specify and validate the relation it
166
163
  receives. This is done using the static <code>relation</code> method:</p>
167
164
 
168
- <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>Queries</span><span class='op'>::</span><span class='const'>User</span><span class='op'>::</span><span class='const'>FetchActive</span> <span class='op'>&lt;</span> <span class='const'>Inquery</span><span class='op'>::</span><span class='const'>Query</span><span class='op'>::</span><span class='const'>Chainable</span>
165
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>Queries</span><span class='op'>::</span><span class='const'>User</span><span class='op'>::</span><span class='const'>FetchActive</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="Inquery.html" title="Inquery (module)">Inquery</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Query</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query/Chainable.html" title="Inquery::Query::Chainable (class)">Chainable</a></span></span>
169
166
  <span class='comment'># This will raise an exception when passing a relation which does not
170
167
  </span> <span class='comment'># correspond to the `User` model.
171
168
  </span> <span class='id identifier rubyid_relation'>relation</span> <span class='label'>class:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>User</span><span class='tstring_end'>&#39;</span></span>
@@ -175,38 +172,34 @@ receives. This is done using the static <code>relation</code> method:</p>
175
172
  </code></pre>
176
173
 
177
174
  <p>The <code>relation</code> method accepts the following options:</p>
178
- <ul><li>
179
- <p><code>class</code></p>
180
175
 
181
- <p>Allows to restrict the class (attribute <code>klass</code>) of the
182
- relation. Use <code>nil</code> to not perform any checks. The
183
- <code>class</code> attribute will also be taken to infer a default if no
184
- relation is given and you didn&#39;t specify any <code>default</code>.</p>
185
- </li><li>
186
- <p><code>default</code></p>
176
+ <ul>
177
+ <li><p><code>class</code></p>
178
+
179
+ <p>Allows to restrict the class (attribute <code>klass</code>) of the relation.
180
+ Use <code>nil</code> to not perform any checks. The <code>class</code> attribute will also
181
+ be taken to infer a default if no relation is given and you didn&#39;t
182
+ specify any <code>default</code>.</p></li>
183
+ <li><p><code>default</code></p>
187
184
 
188
185
  <p>This allows to specify a default relation that will be taken if no relation
189
186
  is given. This must be specified as a Proc returning the relation. Set this
190
- to <code>false</code> for no default. If this is set to <code>nil</code>,
191
- it will try to infer the default from the option <code>class</code> (if
192
- given).</p>
193
- </li><li>
194
- <p><code>fields</code></p>
187
+ to <code>false</code> for no default. If this is set to <code>nil</code>, it will try to infer the
188
+ default from the option <code>class</code> (if given).</p></li>
189
+ <li><p><code>fields</code></p>
195
190
 
196
191
  <p>Allows to restrict the number of fields / values the relation must select.
197
- This is particularly useful if you&#39;re using the query as a subquery and
198
- need it to return exactly one field. Use <code>nil</code> to not perform
199
- any checks.</p>
200
- </li><li>
201
- <p><code>default_select</code></p>
192
+ This is particularly useful if you&#39;re using the query as a subquery and need
193
+ it to return exactly one field. Use <code>nil</code> to not perform any checks.</p></li>
194
+ <li><p><code>default_select</code></p>
202
195
 
203
196
  <p>If this is set to a symbol, the relation does not have any select fields
204
- specified (<code>select_values</code> is empty) and <code>fields</code> is
205
- &gt; 0, it will automatically select the given field. This option defaults
206
- to <code>:id</code>. Use <code>nil</code> to disable this behavior.</p>
207
- </li></ul>
197
+ specified (<code>select_values</code> is empty) and <code>fields</code> is &gt; 0, it will
198
+ automatically select the given field. This option defaults to <code>:id</code>. Use
199
+ <code>nil</code> to disable this behavior.</p></li>
200
+ </ul>
208
201
 
209
- <h3 id="label-Using+query+classes+as+regular+scopes">Using query classes as regular scopes</h3>
202
+ <h3>Using query classes as regular scopes</h3>
210
203
 
211
204
  <p>Chainable queries can also be used as regular AR model scopes:</p>
212
205
 
@@ -214,7 +207,7 @@ to <code>:id</code>. Use <code>nil</code> to disable this behavior.</p>
214
207
  <span class='id identifier rubyid_scope'>scope</span> <span class='symbol'>:active</span><span class='comma'>,</span> <span class='const'>Queries</span><span class='op'>::</span><span class='const'>User</span><span class='op'>::</span><span class='const'>FetchActive</span>
215
208
  <span class='kw'>end</span>
216
209
 
217
- <span class='kw'>class</span> <span class='const'>Queries</span><span class='op'>::</span><span class='const'>User</span><span class='op'>::</span><span class='const'>FetchActive</span> <span class='op'>&lt;</span> <span class='const'>Inquery</span><span class='op'>::</span><span class='const'>Query</span><span class='op'>::</span><span class='const'>Chainable</span>
210
+ <span class='kw'>class</span> <span class='const'>Queries</span><span class='op'>::</span><span class='const'>User</span><span class='op'>::</span><span class='const'>FetchActive</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="Inquery.html" title="Inquery (module)">Inquery</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Query</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query/Chainable.html" title="Inquery::Query::Chainable (class)">Chainable</a></span></span>
218
211
  <span class='comment'># Note that specifying either `class` or `default` is mandatory when using
219
212
  </span> <span class='comment'># this query class as a scope. The reason for this is that, if the scope is
220
213
  </span> <span class='comment'># otherwise empty, the class will receive `nil` from AR and therefore has no
@@ -227,20 +220,18 @@ to <code>:id</code>. Use <code>nil</code> to disable this behavior.</p>
227
220
  <span class='kw'>end</span>
228
221
  </code></pre>
229
222
 
230
- <p>This approach allows to you use short and descriptive code like
231
- <code>User.active</code> but have the possibly complex query code hidden in
232
- a separate, reusable class.</p>
223
+ <p>This approach allows to you use short and descriptive code like <code>User.active</code>
224
+ but have the possibly complex query code hidden in a separate, reusable class.</p>
233
225
 
234
- <p>Note that when using classes as scopes, the <code>process</code> method
235
- will be ignored.</p>
226
+ <p>Note that when using classes as scopes, the <code>process</code> method will be ignored.</p>
236
227
 
237
- <h3 id="label-Using+the+given+relation+as+subquery">Using the given relation as subquery</h3>
228
+ <h3>Using the given relation as subquery</h3>
238
229
 
239
- <p>In simple cases and all the examples above, we just extend the given
240
- relation and return it again. It is also possible however to just use the
241
- given relation as a subquery and return a completely new relation:</p>
230
+ <p>In simple cases and all the examples above, we just extend the given relation
231
+ and return it again. It is also possible however to just use the given relation
232
+ as a subquery and return a completely new relation:</p>
242
233
 
243
- <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>FetchUsersInGroup</span> <span class='op'>&lt;</span> <span class='const'>Inquery</span><span class='op'>::</span><span class='const'>Query</span><span class='op'>::</span><span class='const'>Chainable</span>
234
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>FetchUsersInGroup</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="Inquery.html" title="Inquery (module)">Inquery</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Query</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query/Chainable.html" title="Inquery::Query::Chainable (class)">Chainable</a></span></span>
244
235
  <span class='comment'># Here we do not specify any specific class, as we don&#39;t care for it as long
245
236
  </span> <span class='comment'># as the relation returns exactly one field.
246
237
  </span> <span class='id identifier rubyid_relation'>relation</span> <span class='label'>fields:</span> <span class='int'>1</span>
@@ -270,15 +261,14 @@ given relation as a subquery and return a completely new relation:</p>
270
261
  </span><span class='const'>FetchUsersInGroup</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='const'>Group</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='label'>color:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>red</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
271
262
  </code></pre>
272
263
 
273
- <h2 id="label-Parameters">Parameters</h2>
264
+ <h2>Parameters</h2>
274
265
 
275
- <p>Both query classes can be parameterized using a hash called
276
- <code>params</code>. It is recommended to specify and validate input
277
- parameters in every query. For this purpose, Inquery provides the
278
- <code>schema</code> method witch integrates the <a
279
- href="https://github.com/sitrox/schemacop">Schemacop</a> validation Gem:</p>
266
+ <p>Both query classes can be parameterized using a hash called <code>params</code>. It is
267
+ recommended to specify and validate input parameters in every query. For this
268
+ purpose, Inquery provides the <code>schema</code> method witch integrates the
269
+ <a href="https://github.com/sitrox/schemacop">Schemacop</a> validation Gem:</p>
280
270
 
281
- <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>SomeQueryClass</span> <span class='op'>&lt;</span> <span class='const'>Inquery</span><span class='op'>::</span><span class='const'>Query</span>
271
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>SomeQueryClass</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="Inquery.html" title="Inquery (module)">Inquery</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Query</a></span></span>
282
272
  <span class='id identifier rubyid_schema'>schema</span><span class='lparen'>(</span>
283
273
  <span class='label'>some_param:</span> <span class='symbol'>:integer</span><span class='comma'>,</span>
284
274
  <span class='label'>some_other_param:</span> <span class='lbrace'>{</span>
@@ -293,16 +283,14 @@ href="https://github.com/sitrox/schemacop">Schemacop</a> validation Gem:</p>
293
283
  </code></pre>
294
284
 
295
285
  <p>The schema is validated at query class instantiation. An exception will be
296
- raised if the given params do not match the schema specified. See
297
- documentation of the Schemacop Gem for more information on how to specify
298
- schemas.</p>
286
+ raised if the given params do not match the schema specified. See documentation
287
+ of the Schemacop Gem for more information on how to specify schemas.</p>
299
288
 
300
- <p>Parameters can be accessed using either <code>params</code> or
301
- <code>osparams</code>. The method <code>osparams</code> automatically wraps
302
- <code>params</code> in an <code>OpenStruct</code> for more convenient
289
+ <p>Parameters can be accessed using either <code>params</code> or <code>osparams</code>. The method
290
+ <code>osparams</code> automatically wraps <code>params</code> in an <code>OpenStruct</code> for more convenient
303
291
  access.</p>
304
292
 
305
- <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>SomeQueryClass</span> <span class='op'>&lt;</span> <span class='const'>Inquery</span><span class='op'>::</span><span class='const'>Query</span>
293
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>SomeQueryClass</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="Inquery.html" title="Inquery (module)">Inquery</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Query</a></span></span>
306
294
  <span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span>
307
295
  <span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span>
308
296
  <span class='label'>active:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:active</span><span class='rbracket'>]</span><span class='comma'>,</span>
@@ -312,54 +300,58 @@ access.</p>
312
300
  <span class='kw'>end</span>
313
301
  </code></pre>
314
302
 
315
- <h2 id="label-Rails+integration">Rails integration</h2>
303
+ <h2>Rails integration</h2>
316
304
 
317
305
  <p>While it is optional, Inquery has been written from the ground up to be
318
- perfectly integrated into any Rails application. It has proven to be a
319
- winning concept to extract all complex queries into separate classes that
320
- are independently executable and testable.</p>
321
-
322
- <h3 id="label-Directory+structure">Directory structure</h3>
323
-
324
- <p>While not enforced, it is encouraged to use the following structure for
325
- storing your query classes:</p>
326
- <ul><li>
327
- <p>All domain-specific query classes reside in <code>app/queries</code>.</p>
328
- </li><li>
329
- <p>They&#39;re in the module <code>Queries</code>.</p>
330
- </li><li>
331
- <p>Queries are further grouped by the model they return (and not the model
332
- they receive). For instance, a class fetching all active users could be
333
- located at <code>Queries::User::FetchActive</code> and would reside under
334
- <code>app/queries/user/fetch_active.rb</code>.</p>
335
- </li></ul>
306
+ perfectly integrated into any Rails application. It has proven to be a winning
307
+ concept to extract all complex queries into separate classes that are
308
+ independently executable and testable.</p>
309
+
310
+ <h3>Directory structure</h3>
311
+
312
+ <p>While not enforced, it is encouraged to use the following structure for storing
313
+ your query classes:</p>
314
+
315
+ <ul>
316
+ <li>All domain-specific query classes reside in <code>app/queries</code>.</li>
317
+ <li>They&#39;re in the module <code>Queries</code>.</li>
318
+ <li>Queries are further grouped by the model they return (and not the model
319
+ they receive). For instance, a class fetching all active users could be
320
+ located at <code>Queries::User::FetchActive</code> and would reside under
321
+ <code>app/queries/user/fetch_active.rb</code>.</li>
322
+ </ul>
336
323
 
337
324
  <p>There are some key benefits to this approach:</p>
338
- <ul><li>
339
- <p>As it should, domain-specific code is located within <code>app/</code>.</p>
340
- </li><li>
341
- <p>As queries are grouped by the model they return and consistently named,
342
- they&#39;re easy to locate and it does not take much thought where to put
343
- and how to name new query classes.</p>
344
- </li><li>
345
- <p>As there is a single file per query class, it&#39;s a breeze to list all
346
- queries, i.e. to check their naming for consistency.</p>
347
- </li><li>
348
- <p>If you&#39;re using the same layout for your unit tests, it is absolutely
349
- clear where to find the corresponding unit tests for each one of your
350
- query classes.</p>
351
- </li></ul>
352
-
353
- <h2 id="label-Copyright">Copyright</h2>
354
-
355
- <p>Copyright © 2016 Sitrox. See <code>LICENSE</code> for further details.</p>
325
+
326
+ <ul>
327
+ <li>As it should, domain-specific code is located within <code>app/</code>.</li>
328
+ <li>As queries are grouped by the model they return and consistently named,
329
+ they&#39;re easy to locate and it does not take much thought where to put and
330
+ how to name new query classes.</li>
331
+ <li>As there is a single file per query class, it&#39;s a breeze to list all
332
+ queries, i.e. to check their naming for consistency.</li>
333
+ <li>If you&#39;re using the same layout for your unit tests, it is absolutely
334
+ clear where to find the corresponding unit tests for each one of your
335
+ query classes.</li>
336
+ </ul>
337
+
338
+ <h2>Contributors</h2>
339
+
340
+ <p>Thanks to Jeroen Weeink for his insights regarding using query classes as scopes
341
+ in his <a href="http://craftingruby.com/posts/2015/06/29/query-objects-through-scopes.html">blog post</a>.
342
+ And special thanks to <a href="http://www.subgit.com/">SubGit</a> for their great open source licensing.</p>
343
+
344
+ <h2>Copyright</h2>
345
+
346
+ <p>Copyright (c) 2017 Sitrox. See <code>LICENSE</code> for further details.</p>
356
347
  </div></div>
357
348
 
358
- <div id="footer">
359
- Generated on Thu Jun 9 10:26:30 2016 by
349
+ <div id="footer">
350
+ Generated on Tue May 16 10:49:05 2017 by
360
351
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
361
- 0.8.7.6 (ruby-2.2.3).
352
+ 0.9.9 (ruby-2.3.1).
362
353
  </div>
363
354
 
355
+ </div>
364
356
  </body>
365
357
  </html>