inquery 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.releaser_config +4 -0
- data/.rubocop.yml +42 -0
- data/.travis.yml +9 -0
- data/.yardopts +1 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +288 -0
- data/RUBY_VERSION +1 -0
- data/Rakefile +36 -0
- data/VERSION +1 -0
- data/doc/Inquery.html +119 -0
- data/doc/Inquery/Exceptions.html +115 -0
- data/doc/Inquery/Exceptions/Base.html +127 -0
- data/doc/Inquery/Exceptions/InvalidRelation.html +131 -0
- data/doc/Inquery/Exceptions/UnknownCallSignature.html +131 -0
- data/doc/Inquery/Mixins.html +117 -0
- data/doc/Inquery/Mixins/RelationValidation.html +334 -0
- data/doc/Inquery/Mixins/RelationValidation/ClassMethods.html +190 -0
- data/doc/Inquery/Mixins/SchemaValidation.html +124 -0
- data/doc/Inquery/Mixins/SchemaValidation/ClassMethods.html +192 -0
- data/doc/Inquery/Query.html +736 -0
- data/doc/Inquery/Query/Chainable.html +476 -0
- data/doc/_index.html +254 -0
- data/doc/class_list.html +58 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +339 -0
- data/doc/file.README.html +365 -0
- data/doc/file_list.html +60 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +365 -0
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +181 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +147 -0
- data/doc/top-level-namespace.html +112 -0
- data/inquery.gemspec +58 -0
- data/lib/inquery.rb +10 -0
- data/lib/inquery/exceptions.rb +7 -0
- data/lib/inquery/mixins/relation_validation.rb +100 -0
- data/lib/inquery/mixins/schema_validation.rb +27 -0
- data/lib/inquery/query.rb +50 -0
- data/lib/inquery/query/chainable.rb +53 -0
- data/test/db/models.rb +20 -0
- data/test/db/schema.rb +20 -0
- data/test/inquery/query/chainable_test.rb +67 -0
- data/test/inquery/query_test.rb +47 -0
- data/test/queries/group/fetch_as_json.rb +13 -0
- data/test/queries/group/fetch_green.rb +11 -0
- data/test/queries/group/fetch_red.rb +11 -0
- data/test/queries/group/filter_with_color.rb +12 -0
- data/test/queries/user/fetch_all.rb +9 -0
- data/test/queries/user/fetch_in_group.rb +13 -0
- data/test/queries/user/fetch_in_group_rel.rb +17 -0
- data/test/test_helper.rb +26 -0
- metadata +265 -0
@@ -0,0 +1,131 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Exception: Inquery::Exceptions::UnknownCallSignature
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.7.6
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../../';
|
20
|
+
framesUrl = "../../frames.html#!Inquery/Exceptions/UnknownCallSignature.html";
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../../_index.html">Index (U)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../../Inquery.html" title="Inquery (module)">Inquery</a></span></span> » <span class='title'><span class='object_link'><a href="../Exceptions.html" title="Inquery::Exceptions (module)">Exceptions</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">UnknownCallSignature</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Exception: Inquery::Exceptions::UnknownCallSignature
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
<dt class="r1">Inherits:</dt>
|
75
|
+
<dd class="r1">
|
76
|
+
<span class="inheritName"><span class='object_link'><a href="Base.html" title="Inquery::Exceptions::Base (class)">Base</a></span></span>
|
77
|
+
|
78
|
+
<ul class="fullTree">
|
79
|
+
<li>Object</li>
|
80
|
+
|
81
|
+
<li class="next">StandardError</li>
|
82
|
+
|
83
|
+
<li class="next"><span class='object_link'><a href="Base.html" title="Inquery::Exceptions::Base (class)">Base</a></span></li>
|
84
|
+
|
85
|
+
<li class="next">Inquery::Exceptions::UnknownCallSignature</li>
|
86
|
+
|
87
|
+
</ul>
|
88
|
+
<a href="#" class="inheritanceTree">show all</a>
|
89
|
+
|
90
|
+
</dd>
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
<dt class="r2 last">Defined in:</dt>
|
101
|
+
<dd class="r2 last">lib/inquery/exceptions.rb</dd>
|
102
|
+
|
103
|
+
</dl>
|
104
|
+
<div class="clear"></div>
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
</div>
|
123
|
+
|
124
|
+
<div id="footer">
|
125
|
+
Generated on Thu Jun 9 10:26:31 2016 by
|
126
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
127
|
+
0.8.7.6 (ruby-2.2.3).
|
128
|
+
</div>
|
129
|
+
|
130
|
+
</body>
|
131
|
+
</html>
|
@@ -0,0 +1,117 @@
|
|
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: Inquery::Mixins
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.7.6
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../';
|
20
|
+
framesUrl = "../frames.html#!Inquery/Mixins.html";
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../_index.html">Index (M)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../Inquery.html" title="Inquery (module)">Inquery</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">Mixins</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Module: Inquery::Mixins
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<dt class="r1 last">Defined in:</dt>
|
82
|
+
<dd class="r1 last">lib/inquery/mixins/schema_validation.rb<span class="defines">,<br />
|
83
|
+
lib/inquery/mixins/relation_validation.rb</span>
|
84
|
+
</dd>
|
85
|
+
|
86
|
+
</dl>
|
87
|
+
<div class="clear"></div>
|
88
|
+
|
89
|
+
<h2>Defined Under Namespace</h2>
|
90
|
+
<p class="children">
|
91
|
+
|
92
|
+
|
93
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Mixins/RelationValidation.html" title="Inquery::Mixins::RelationValidation (module)">RelationValidation</a></span>, <span class='object_link'><a href="Mixins/SchemaValidation.html" title="Inquery::Mixins::SchemaValidation (module)">SchemaValidation</a></span>
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
</p>
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
</div>
|
109
|
+
|
110
|
+
<div id="footer">
|
111
|
+
Generated on Thu Jun 9 10:26:31 2016 by
|
112
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
113
|
+
0.8.7.6 (ruby-2.2.3).
|
114
|
+
</div>
|
115
|
+
|
116
|
+
</body>
|
117
|
+
</html>
|
@@ -0,0 +1,334 @@
|
|
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: Inquery::Mixins::RelationValidation
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.7.6
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../../';
|
20
|
+
framesUrl = "../../frames.html#!Inquery/Mixins/RelationValidation.html";
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../../_index.html">Index (R)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../../Inquery.html" title="Inquery (module)">Inquery</a></span></span> » <span class='title'><span class='object_link'><a href="../Mixins.html" title="Inquery::Mixins (module)">Mixins</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">RelationValidation</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Module: Inquery::Mixins::RelationValidation
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
<dt class="r1">Extended by:</dt>
|
77
|
+
<dd class="r1">ActiveSupport::Concern</dd>
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
<dt class="r2">Included in:</dt>
|
85
|
+
<dd class="r2"><span class='object_link'><a href="../Query/Chainable.html" title="Inquery::Query::Chainable (class)">Query::Chainable</a></span></dd>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
<dt class="r1 last">Defined in:</dt>
|
90
|
+
<dd class="r1 last">lib/inquery/mixins/relation_validation.rb</dd>
|
91
|
+
|
92
|
+
</dl>
|
93
|
+
<div class="clear"></div>
|
94
|
+
|
95
|
+
<h2>Defined Under Namespace</h2>
|
96
|
+
<p class="children">
|
97
|
+
|
98
|
+
|
99
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="RelationValidation/ClassMethods.html" title="Inquery::Mixins::RelationValidation::ClassMethods (module)">ClassMethods</a></span>
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
</p>
|
105
|
+
|
106
|
+
<h2>Constant Summary</h2>
|
107
|
+
|
108
|
+
<dl class="constants">
|
109
|
+
|
110
|
+
<dt id="OPTIONS_SCHEMA-constant" class="">OPTIONS_SCHEMA =
|
111
|
+
|
112
|
+
</dt>
|
113
|
+
<dd><pre class="code"><span class='lbrace'>{</span>
|
114
|
+
<span class='label'>hash:</span> <span class='lbrace'>{</span>
|
115
|
+
<span class='label'>class:</span> <span class='lbrace'>{</span> <span class='label'>type:</span> <span class='const'>String</span><span class='comma'>,</span> <span class='label'>null:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>required:</span> <span class='kw'>false</span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
116
|
+
<span class='label'>fields:</span> <span class='lbrace'>{</span> <span class='label'>type:</span> <span class='symbol'>:integer</span><span class='comma'>,</span> <span class='label'>null:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>required:</span> <span class='kw'>false</span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
117
|
+
<span class='label'>default_select:</span> <span class='lbrace'>{</span> <span class='label'>type:</span> <span class='symbol'>:symbol</span><span class='comma'>,</span> <span class='label'>null:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>required:</span> <span class='kw'>false</span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
118
|
+
<span class='label'>default:</span> <span class='lbrace'>{</span> <span class='label'>type:</span> <span class='lbracket'>[</span><span class='const'>Proc</span><span class='comma'>,</span> <span class='const'>FalseClass</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>null:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>required:</span> <span class='kw'>false</span> <span class='rbrace'>}</span>
|
119
|
+
<span class='rbrace'>}</span>
|
120
|
+
<span class='rbrace'>}</span></pre></dd>
|
121
|
+
|
122
|
+
<dt id="DEFAULT_OPTIONS-constant" class="">DEFAULT_OPTIONS =
|
123
|
+
|
124
|
+
</dt>
|
125
|
+
<dd><pre class="code"><span class='lbrace'>{</span>
|
126
|
+
<span class='comment'># Allows to restrict the class (attribute `klass`) of the relation. Use
|
127
|
+
</span> <span class='comment'># `nil` to not perform any checks. The `class` attribute will also be
|
128
|
+
</span> <span class='comment'># taken to infer a default if no relation is given and you didn't
|
129
|
+
</span> <span class='comment'># specify any `default`.
|
130
|
+
</span> <span class='label'>class:</span> <span class='kw'>nil</span><span class='comma'>,</span>
|
131
|
+
|
132
|
+
<span class='comment'># This allows to specify a default relation that will be taken if no
|
133
|
+
</span> <span class='comment'># relation is given. This must be specified as a Proc returning the
|
134
|
+
</span> <span class='comment'># relation. Set this to `false` for no default. If this is set to `nil`,
|
135
|
+
</span> <span class='comment'># it will try to infer the default from the option `class` (if given).
|
136
|
+
</span> <span class='label'>default:</span> <span class='kw'>nil</span><span class='comma'>,</span>
|
137
|
+
|
138
|
+
<span class='comment'># Allows to restrict the number of fields / values the relation must
|
139
|
+
</span> <span class='comment'># select. This is particularly useful if you're using the query as a
|
140
|
+
</span> <span class='comment'># subquery and need it to return exactly one field. Use `nil` to not
|
141
|
+
</span> <span class='comment'># perform any checks.
|
142
|
+
</span> <span class='label'>fields:</span> <span class='kw'>nil</span><span class='comma'>,</span>
|
143
|
+
|
144
|
+
<span class='comment'># If this is set to a symbol, the relation does not have any select
|
145
|
+
</span> <span class='comment'># fields specified (`select_values` is empty) and `fields` is > 0, it
|
146
|
+
</span> <span class='comment'># will automatically select the given field. Use `nil` to disable this
|
147
|
+
</span> <span class='comment'># behavior.
|
148
|
+
</span> <span class='label'>default_select:</span> <span class='symbol'>:id</span>
|
149
|
+
<span class='rbrace'>}</span></pre></dd>
|
150
|
+
|
151
|
+
</dl>
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
<h2>
|
162
|
+
Instance Method Summary
|
163
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
164
|
+
</h2>
|
165
|
+
|
166
|
+
<ul class="summary">
|
167
|
+
|
168
|
+
<li class="public ">
|
169
|
+
<span class="summary_signature">
|
170
|
+
|
171
|
+
<a href="#validate_relation%21-instance_method" title="#validate_relation! (instance method)">- (Object) <strong>validate_relation!</strong>(relation) </a>
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
</span>
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
<span class="summary_desc"><div class='inline'>
|
186
|
+
<p>Validates (and possibly alters) the given relation according to the options
|
187
|
+
specified at class level using the <code>relation</code> method.</p>
|
188
|
+
</div></span>
|
189
|
+
|
190
|
+
</li>
|
191
|
+
|
192
|
+
|
193
|
+
</ul>
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
<div id="instance_method_details" class="method_details_list">
|
200
|
+
<h2>Instance Method Details</h2>
|
201
|
+
|
202
|
+
|
203
|
+
<div class="method_details first">
|
204
|
+
<h3 class="signature first" id="validate_relation!-instance_method">
|
205
|
+
|
206
|
+
- (<tt>Object</tt>) <strong>validate_relation!</strong>(relation)
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
</h3><div class="docstring">
|
213
|
+
<div class="discussion">
|
214
|
+
|
215
|
+
<p>Validates (and possibly alters) the given relation according to the options
|
216
|
+
specified at class level using the <code>relation</code> method.</p>
|
217
|
+
|
218
|
+
|
219
|
+
</div>
|
220
|
+
</div>
|
221
|
+
<div class="tags">
|
222
|
+
|
223
|
+
|
224
|
+
</div><table class="source_code">
|
225
|
+
<tr>
|
226
|
+
<td>
|
227
|
+
<pre class="lines">
|
228
|
+
|
229
|
+
|
230
|
+
56
|
231
|
+
57
|
232
|
+
58
|
233
|
+
59
|
234
|
+
60
|
235
|
+
61
|
236
|
+
62
|
237
|
+
63
|
238
|
+
64
|
239
|
+
65
|
240
|
+
66
|
241
|
+
67
|
242
|
+
68
|
243
|
+
69
|
244
|
+
70
|
245
|
+
71
|
246
|
+
72
|
247
|
+
73
|
248
|
+
74
|
249
|
+
75
|
250
|
+
76
|
251
|
+
77
|
252
|
+
78
|
253
|
+
79
|
254
|
+
80
|
255
|
+
81
|
256
|
+
82
|
257
|
+
83
|
258
|
+
84
|
259
|
+
85
|
260
|
+
86
|
261
|
+
87
|
262
|
+
88
|
263
|
+
89
|
264
|
+
90
|
265
|
+
91
|
266
|
+
92
|
267
|
+
93
|
268
|
+
94
|
269
|
+
95
|
270
|
+
96
|
271
|
+
97</pre>
|
272
|
+
</td>
|
273
|
+
<td>
|
274
|
+
<pre class="code"><span class="info file"># File 'lib/inquery/mixins/relation_validation.rb', line 56</span>
|
275
|
+
|
276
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_validate_relation!'>validate_relation!</span><span class='lparen'>(</span><span class='id identifier rubyid_relation'>relation</span><span class='rparen'>)</span>
|
277
|
+
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='const'>DEFAULT_OPTIONS</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span>
|
278
|
+
<span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid__relation_options'>_relation_options</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid__relation_options'>_relation_options</span>
|
279
|
+
|
280
|
+
<span class='id identifier rubyid_relation_class'>relation_class</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:class</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:constantize</span><span class='rparen'>)</span>
|
281
|
+
|
282
|
+
<span class='comment'># ---------------------------------------------------------------
|
283
|
+
</span> <span class='comment'># Validate presence
|
284
|
+
</span> <span class='comment'># ---------------------------------------------------------------
|
285
|
+
</span> <span class='kw'>if</span> <span class='id identifier rubyid_relation'>relation</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
286
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:default</span><span class='rbracket'>]</span>
|
287
|
+
<span class='id identifier rubyid_relation'>relation</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:default</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
|
288
|
+
<span class='kw'>elsif</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:default</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_relation_class'>relation_class</span>
|
289
|
+
<span class='id identifier rubyid_relation'>relation</span> <span class='op'>=</span> <span class='id identifier rubyid_relation_class'>relation_class</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span>
|
290
|
+
<span class='kw'>else</span>
|
291
|
+
<span class='id identifier rubyid_fail'>fail</span> <span class='const'>Inquery</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>InvalidRelation</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>A relation must be given for this query.</span><span class='tstring_end'>'</span></span>
|
292
|
+
<span class='kw'>end</span>
|
293
|
+
<span class='kw'>end</span>
|
294
|
+
|
295
|
+
<span class='comment'># ---------------------------------------------------------------
|
296
|
+
</span> <span class='comment'># Validate class
|
297
|
+
</span> <span class='comment'># ---------------------------------------------------------------
|
298
|
+
</span> <span class='kw'>if</span> <span class='id identifier rubyid_relation_class'>relation_class</span> <span class='op'>&&</span> <span class='id identifier rubyid_relation_class'>relation_class</span> <span class='op'>!=</span> <span class='id identifier rubyid_relation'>relation</span><span class='period'>.</span><span class='id identifier rubyid_klass'>klass</span>
|
299
|
+
<span class='id identifier rubyid_fail'>fail</span> <span class='const'>Inquery</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>InvalidRelation</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Unexpected relation class '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_relation'>relation</span><span class='period'>.</span><span class='id identifier rubyid_klass'>klass</span><span class='embexpr_end'>}</span><span class='tstring_content'>' for this query, expected a '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_relation_class'>relation_class</span><span class='embexpr_end'>}</span><span class='tstring_content'>'.</span><span class='tstring_end'>"</span></span>
|
300
|
+
<span class='kw'>end</span>
|
301
|
+
|
302
|
+
<span class='comment'># ---------------------------------------------------------------
|
303
|
+
</span> <span class='comment'># Validate selected fields
|
304
|
+
</span> <span class='comment'># ---------------------------------------------------------------
|
305
|
+
</span> <span class='id identifier rubyid_fields_count'>fields_count</span> <span class='op'>=</span> <span class='id identifier rubyid_relation'>relation</span><span class='period'>.</span><span class='id identifier rubyid_select_values'>select_values</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span>
|
306
|
+
|
307
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_fields_count'>fields_count</span> <span class='op'>==</span> <span class='int'>0</span> <span class='op'>&&</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:default_select</span><span class='rbracket'>]</span> <span class='op'>&&</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:fields</span><span class='rbracket'>]</span> <span class='op'>&&</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:fields</span><span class='rbracket'>]</span> <span class='op'>></span> <span class='int'>0</span>
|
308
|
+
<span class='id identifier rubyid_relation'>relation</span> <span class='op'>=</span> <span class='id identifier rubyid_relation'>relation</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:default_select</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
309
|
+
<span class='id identifier rubyid_fields_count'>fields_count</span> <span class='op'>=</span> <span class='int'>1</span>
|
310
|
+
<span class='kw'>end</span>
|
311
|
+
|
312
|
+
<span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:fields</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_fields_count'>fields_count</span> <span class='op'>!=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:fields</span><span class='rbracket'>]</span>
|
313
|
+
<span class='id identifier rubyid_fail'>fail</span> <span class='const'>Inquery</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>InvalidRelation</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Expected given relation to select </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:fields</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'> field(s) but got </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_fields_count'>fields_count</span><span class='embexpr_end'>}</span><span class='tstring_content'>.</span><span class='tstring_end'>"</span></span>
|
314
|
+
<span class='kw'>end</span>
|
315
|
+
|
316
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_relation'>relation</span>
|
317
|
+
<span class='kw'>end</span></pre>
|
318
|
+
</td>
|
319
|
+
</tr>
|
320
|
+
</table>
|
321
|
+
</div>
|
322
|
+
|
323
|
+
</div>
|
324
|
+
|
325
|
+
</div>
|
326
|
+
|
327
|
+
<div id="footer">
|
328
|
+
Generated on Thu Jun 9 10:26:31 2016 by
|
329
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
330
|
+
0.8.7.6 (ruby-2.2.3).
|
331
|
+
</div>
|
332
|
+
|
333
|
+
</body>
|
334
|
+
</html>
|