active-record-binder 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +217 -0
- data/bin/arb +13 -0
- data/doc/Binder.html +150 -0
- data/doc/Binder/AR.html +1880 -0
- data/doc/Binder/Command.html +252 -0
- data/doc/Binder/Help.html +374 -0
- data/doc/Binder/Migrate.html +682 -0
- data/doc/Binder/Strategy.html +550 -0
- data/doc/Binder/Version.html +285 -0
- data/doc/Class.html +220 -0
- data/doc/CommandParser.html +268 -0
- data/doc/CommandParser/ParseError.html +123 -0
- data/doc/DeferedDelegator.html +414 -0
- data/doc/MigrationProcessError.html +123 -0
- data/doc/MigrationVersionError.html +123 -0
- data/doc/String.html +245 -0
- data/doc/_index.html +256 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file.README.html +300 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +300 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +348 -0
- data/doc/top-level-namespace.html +114 -0
- data/extras/cli_help.png +0 -0
- data/lib/active_record_binder.rb +21 -37
- data/lib/cli/command.rb +101 -0
- data/lib/cli/command_parser.rb +29 -0
- data/lib/cli/commands/commands.rb +4 -0
- data/lib/cli/commands/help.rb +35 -0
- data/lib/cli/commands/migrate.rb +77 -0
- data/lib/cli/commands/version.rb +16 -0
- data/lib/cli/core_ext.rb +21 -0
- data/lib/defered_delegator.rb +69 -0
- data/lib/version.rb +3 -0
- data/test/active_record_binder_test.rb +262 -0
- data/test/foo.sqlite3 +0 -0
- data/test/migrations.rb +29 -0
- data/test/minitest_helper.rb +15 -0
- data/test/mocks.rb +24 -0
- metadata +62 -5
@@ -0,0 +1,268 @@
|
|
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: CommandParser
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.4.1
|
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
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '';
|
20
|
+
framesUrl = "frames.html#!" + escape(window.location.href);
|
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 (C)</a> »
|
35
|
+
|
36
|
+
|
37
|
+
<span class="title">CommandParser</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: CommandParser
|
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/cli/command_parser.rb</dd>
|
83
|
+
|
84
|
+
</dl>
|
85
|
+
<div class="clear"></div>
|
86
|
+
|
87
|
+
<h2>Defined Under Namespace</h2>
|
88
|
+
<p class="children">
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="CommandParser/ParseError.html" title="CommandParser::ParseError (class)">ParseError</a></span>
|
94
|
+
|
95
|
+
|
96
|
+
</p>
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
<h2>
|
106
|
+
Class Method Summary
|
107
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
108
|
+
</h2>
|
109
|
+
|
110
|
+
<ul class="summary">
|
111
|
+
|
112
|
+
<li class="public ">
|
113
|
+
<span class="summary_signature">
|
114
|
+
|
115
|
+
<a href="#parse_options-class_method" title="parse_options (class method)">+ (Object) <strong>parse_options</strong>(args) </a>
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
</span>
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
<span class="summary_desc"><div class='inline'>
|
130
|
+
<p>Parse options and creates an array of hash data for each.</p>
|
131
|
+
</div></span>
|
132
|
+
|
133
|
+
</li>
|
134
|
+
|
135
|
+
|
136
|
+
</ul>
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
<div id="class_method_details" class="method_details_list">
|
142
|
+
<h2>Class Method Details</h2>
|
143
|
+
|
144
|
+
|
145
|
+
<div class="method_details first">
|
146
|
+
<h3 class="signature first" id="parse_options-class_method">
|
147
|
+
|
148
|
+
+ (<tt>Object</tt>) <strong>parse_options</strong>(args)
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
</h3><div class="docstring">
|
155
|
+
<div class="discussion">
|
156
|
+
|
157
|
+
<p>Parse options and creates an array of hash data for each.</p>
|
158
|
+
|
159
|
+
|
160
|
+
</div>
|
161
|
+
</div>
|
162
|
+
<div class="tags">
|
163
|
+
|
164
|
+
<div class="examples">
|
165
|
+
<p class="tag_title">Examples:</p>
|
166
|
+
|
167
|
+
|
168
|
+
<pre class="example code"><code><span class='const'>CommandParser</span><span class='op'>::</span><span class='id identifier rubyid_parse_options'>parse_options</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>--directory lib/ migrations/ --adapter MySqlPlug</span><span class='tstring_end'>"</span></span>
|
169
|
+
<span class='comment'># => [{ option: 'directory', option_args: ["lib/", "migrations/"] }, { option: 'adapter', option_args: ["MySqlPlug"] }]</span></code></pre>
|
170
|
+
|
171
|
+
</div>
|
172
|
+
<p class="tag_title">Parameters:</p>
|
173
|
+
<ul class="param">
|
174
|
+
|
175
|
+
<li>
|
176
|
+
|
177
|
+
<span class='name'>args</span>
|
178
|
+
|
179
|
+
|
180
|
+
<span class='type'></span>
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
—
|
185
|
+
<div class='inline'>
|
186
|
+
<p>An Array of options and parameters to parse.</p>
|
187
|
+
</div>
|
188
|
+
|
189
|
+
</li>
|
190
|
+
|
191
|
+
</ul>
|
192
|
+
|
193
|
+
<p class="tag_title">Returns:</p>
|
194
|
+
<ul class="return">
|
195
|
+
|
196
|
+
<li>
|
197
|
+
|
198
|
+
|
199
|
+
<span class='type'></span>
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
<div class='inline'>
|
205
|
+
<p>a parsed array.</p>
|
206
|
+
</div>
|
207
|
+
|
208
|
+
</li>
|
209
|
+
|
210
|
+
</ul>
|
211
|
+
|
212
|
+
</div><table class="source_code">
|
213
|
+
<tr>
|
214
|
+
<td>
|
215
|
+
<pre class="lines">
|
216
|
+
|
217
|
+
|
218
|
+
12
|
219
|
+
13
|
220
|
+
14
|
221
|
+
15
|
222
|
+
16
|
223
|
+
17
|
224
|
+
18
|
225
|
+
19
|
226
|
+
20
|
227
|
+
21
|
228
|
+
22
|
229
|
+
23
|
230
|
+
24
|
231
|
+
25
|
232
|
+
26</pre>
|
233
|
+
</td>
|
234
|
+
<td>
|
235
|
+
<pre class="code"><span class="info file"># File 'lib/cli/command_parser.rb', line 12</span>
|
236
|
+
|
237
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parse_options'>parse_options</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
238
|
+
<span class='id identifier rubyid_parsed'>parsed</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
239
|
+
<span class='id identifier rubyid_last_option'>last_option</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span>
|
240
|
+
<span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_chunk'>chunk</span><span class='op'>|</span>
|
241
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_chunk'>chunk</span><span class='lbracket'>[</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-*</span><span class='regexp_end'>/</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
|
242
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>CommandParser</span><span class='op'>::</span><span class='const'>ParseError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Arguments given but no option has been specified.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_last_option'>last_option</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
|
243
|
+
<span class='id identifier rubyid_cur_cmd'>cur_cmd</span> <span class='op'>=</span> <span class='id identifier rubyid_parsed'>parsed</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span>
|
244
|
+
<span class='id identifier rubyid_cur_cmd'>cur_cmd</span><span class='lbracket'>[</span><span class='symbol'>:options_args</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
245
|
+
<span class='id identifier rubyid_cur_cmd'>cur_cmd</span><span class='lbracket'>[</span><span class='symbol'>:options_args</span><span class='rbracket'>]</span> <span class='op'><<</span> <span class='id identifier rubyid_chunk'>chunk</span>
|
246
|
+
<span class='kw'>else</span>
|
247
|
+
<span class='id identifier rubyid_parsed'>parsed</span> <span class='op'><<</span> <span class='lbrace'>{</span> <span class='label'>option:</span> <span class='id identifier rubyid_chunk'>chunk</span><span class='period'>.</span><span class='id identifier rubyid_sub'>sub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^-*</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='kw'>and</span> <span class='id identifier rubyid_last_option'>last_option</span> <span class='op'>=</span> <span class='id identifier rubyid_chunk'>chunk</span>
|
248
|
+
<span class='kw'>end</span>
|
249
|
+
<span class='kw'>end</span>
|
250
|
+
<span class='id identifier rubyid_parsed'>parsed</span>
|
251
|
+
<span class='kw'>end</span></pre>
|
252
|
+
</td>
|
253
|
+
</tr>
|
254
|
+
</table>
|
255
|
+
</div>
|
256
|
+
|
257
|
+
</div>
|
258
|
+
|
259
|
+
</div>
|
260
|
+
|
261
|
+
<div id="footer">
|
262
|
+
Generated on Thu Feb 21 02:06:16 2013 by
|
263
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
264
|
+
0.8.4.1 (ruby-1.9.3).
|
265
|
+
</div>
|
266
|
+
|
267
|
+
</body>
|
268
|
+
</html>
|
@@ -0,0 +1,123 @@
|
|
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: CommandParser::ParseError
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.4.1
|
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
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../';
|
20
|
+
framesUrl = "../frames.html#!" + escape(window.location.href);
|
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 (P)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../CommandParser.html" title="CommandParser (module)">CommandParser</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">ParseError</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: CommandParser::ParseError
|
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">StandardError</span>
|
77
|
+
|
78
|
+
<ul class="fullTree">
|
79
|
+
<li>Object</li>
|
80
|
+
|
81
|
+
<li class="next">StandardError</li>
|
82
|
+
|
83
|
+
<li class="next">CommandParser::ParseError</li>
|
84
|
+
|
85
|
+
</ul>
|
86
|
+
<a href="#" class="inheritanceTree">show all</a>
|
87
|
+
|
88
|
+
</dd>
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
<dt class="r2 last">Defined in:</dt>
|
99
|
+
<dd class="r2 last">lib/cli/command_parser.rb</dd>
|
100
|
+
|
101
|
+
</dl>
|
102
|
+
<div class="clear"></div>
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
</div>
|
115
|
+
|
116
|
+
<div id="footer">
|
117
|
+
Generated on Thu Feb 21 02:06:17 2013 by
|
118
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
119
|
+
0.8.4.1 (ruby-1.9.3).
|
120
|
+
</div>
|
121
|
+
|
122
|
+
</body>
|
123
|
+
</html>
|
@@ -0,0 +1,414 @@
|
|
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: DeferedDelegator
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.4.1
|
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
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '';
|
20
|
+
framesUrl = "frames.html#!" + escape(window.location.href);
|
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 (D)</a> »
|
35
|
+
|
36
|
+
|
37
|
+
<span class="title">DeferedDelegator</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: DeferedDelegator
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
<dt class="r1">Included in:</dt>
|
81
|
+
<dd class="r1"><span class='object_link'><a href="Binder/AR.html" title="Binder::AR (class)">Binder::AR</a></span></dd>
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
<dt class="r2 last">Defined in:</dt>
|
86
|
+
<dd class="r2 last">lib/defered_delegator.rb</dd>
|
87
|
+
|
88
|
+
</dl>
|
89
|
+
<div class="clear"></div>
|
90
|
+
|
91
|
+
<h2>Overview</h2><div class="docstring">
|
92
|
+
<div class="discussion">
|
93
|
+
|
94
|
+
<p>Private: A simple module that delegates classes methods when needed,
|
95
|
+
keeping the calls in memory.</p>
|
96
|
+
|
97
|
+
|
98
|
+
</div>
|
99
|
+
</div>
|
100
|
+
<div class="tags">
|
101
|
+
|
102
|
+
<div class="examples">
|
103
|
+
<p class="tag_title">Examples:</p>
|
104
|
+
|
105
|
+
|
106
|
+
<pre class="example code"><code><span class='kw'>class</span> <span class='const'>Foo</span>
|
107
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_foo'>foo</span> <span class='id identifier rubyid_arg'>arg</span>
|
108
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>World of </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_arg'>arg</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
109
|
+
<span class='kw'>end</span>
|
110
|
+
<span class='comment'>#
|
111
|
+
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_bar'>bar</span>
|
112
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Hello</span><span class='tstring_end'>"</span></span>
|
113
|
+
<span class='kw'>end</span>
|
114
|
+
<span class='kw'>end</span></code></pre>
|
115
|
+
|
116
|
+
|
117
|
+
<pre class="example code"><code><span class='kw'>class</span> <span class='const'>Baz</span>
|
118
|
+
<span class='id identifier rubyid_extend'>extend</span> <span class='const'>DeferedDelegator</span>
|
119
|
+
<span class='id identifier rubyid_register_delegators'>register_delegators</span> <span class='symbol'>:bar</span><span class='comma'>,</span> <span class='symbol'>:foo</span>
|
120
|
+
<span class='comment'>#
|
121
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span> <span class='id identifier rubyid_obj'>obj</span>
|
122
|
+
<span class='ivar'>@obj</span> <span class='op'>=</span> <span class='id identifier rubyid_obj'>obj</span>
|
123
|
+
<span class='kw'>end</span>
|
124
|
+
<span class='comment'>#
|
125
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_foobar'>foobar</span>
|
126
|
+
<span class='id identifier rubyid_delegate_to'>delegate_to</span> <span class='ivar'>@obj</span>
|
127
|
+
<span class='kw'>end</span>
|
128
|
+
<span class='kw'>end</span></code></pre>
|
129
|
+
|
130
|
+
|
131
|
+
<pre class="example code"><code><span class='kw'>class</span> <span class='const'>Bar</span> <span class='op'><</span> <span class='const'>Baz</span>
|
132
|
+
<span class='id identifier rubyid_foo'>foo</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Foo</span><span class='tstring_end'>"</span></span>
|
133
|
+
<span class='id identifier rubyid_bar'>bar</span>
|
134
|
+
<span class='kw'>end</span></code></pre>
|
135
|
+
|
136
|
+
|
137
|
+
<pre class="example code"><code><span class='const'>Bar</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='const'>Foo</span>
|
138
|
+
<span class='const'>Bar</span><span class='period'>.</span><span class='id identifier rubyid_foobar'>foobar</span>
|
139
|
+
<span class='comment'># => "World of Foo"
|
140
|
+
</span><span class='comment'># => "Hello"</span></code></pre>
|
141
|
+
|
142
|
+
</div>
|
143
|
+
|
144
|
+
|
145
|
+
</div>
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
<h2>
|
154
|
+
Instance Method Summary
|
155
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
156
|
+
</h2>
|
157
|
+
|
158
|
+
<ul class="summary">
|
159
|
+
|
160
|
+
<li class="public ">
|
161
|
+
<span class="summary_signature">
|
162
|
+
|
163
|
+
<a href="#delegate_to-instance_method" title="#delegate_to (instance method)">- (Object) <strong>delegate_to</strong>(klass_or_object) </a>
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
</span>
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
<span class="summary_desc"><div class='inline'>
|
178
|
+
<p>Triggers the delegation and run the delegated methods.</p>
|
179
|
+
</div></span>
|
180
|
+
|
181
|
+
</li>
|
182
|
+
|
183
|
+
|
184
|
+
<li class="public ">
|
185
|
+
<span class="summary_signature">
|
186
|
+
|
187
|
+
<a href="#register_delegators-instance_method" title="#register_delegators (instance method)">- (Object) <strong>register_delegators</strong>(*args) </a>
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
</span>
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
<span class="summary_desc"><div class='inline'>
|
202
|
+
<p>Allows to register delegators.</p>
|
203
|
+
</div></span>
|
204
|
+
|
205
|
+
</li>
|
206
|
+
|
207
|
+
|
208
|
+
</ul>
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
<div id="instance_method_details" class="method_details_list">
|
214
|
+
<h2>Instance Method Details</h2>
|
215
|
+
|
216
|
+
|
217
|
+
<div class="method_details first">
|
218
|
+
<h3 class="signature first" id="delegate_to-instance_method">
|
219
|
+
|
220
|
+
- (<tt>Object</tt>) <strong>delegate_to</strong>(klass_or_object)
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
</h3><div class="docstring">
|
227
|
+
<div class="discussion">
|
228
|
+
|
229
|
+
<p>Triggers the delegation and run the delegated methods</p>
|
230
|
+
|
231
|
+
|
232
|
+
</div>
|
233
|
+
</div>
|
234
|
+
<div class="tags">
|
235
|
+
<p class="tag_title">Parameters:</p>
|
236
|
+
<ul class="param">
|
237
|
+
|
238
|
+
<li>
|
239
|
+
|
240
|
+
<span class='name'>klass_or_object</span>
|
241
|
+
|
242
|
+
|
243
|
+
<span class='type'></span>
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
—
|
248
|
+
<div class='inline'>
|
249
|
+
<p>A Class or an Object to delegate to.</p>
|
250
|
+
</div>
|
251
|
+
|
252
|
+
</li>
|
253
|
+
|
254
|
+
</ul>
|
255
|
+
|
256
|
+
<p class="tag_title">Returns:</p>
|
257
|
+
<ul class="return">
|
258
|
+
|
259
|
+
<li>
|
260
|
+
|
261
|
+
|
262
|
+
<span class='type'></span>
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
<div class='inline'>
|
268
|
+
<p>Nothing.</p>
|
269
|
+
</div>
|
270
|
+
|
271
|
+
</li>
|
272
|
+
|
273
|
+
</ul>
|
274
|
+
|
275
|
+
</div><table class="source_code">
|
276
|
+
<tr>
|
277
|
+
<td>
|
278
|
+
<pre class="lines">
|
279
|
+
|
280
|
+
|
281
|
+
60
|
282
|
+
61
|
283
|
+
62
|
284
|
+
63
|
285
|
+
64
|
286
|
+
65
|
287
|
+
66
|
288
|
+
67
|
289
|
+
68</pre>
|
290
|
+
</td>
|
291
|
+
<td>
|
292
|
+
<pre class="code"><span class="info file"># File 'lib/defered_delegator.rb', line 60</span>
|
293
|
+
|
294
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_delegate_to'>delegate_to</span> <span class='id identifier rubyid_klass_or_object'>klass_or_object</span>
|
295
|
+
<span class='ivar'>@delegators</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_data'>data</span><span class='op'>|</span>
|
296
|
+
<span class='kw'>unless</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
|
297
|
+
<span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span>
|
298
|
+
<span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='symbol'>:params</span><span class='rbracket'>]</span>
|
299
|
+
<span class='id identifier rubyid_klass_or_object'>klass_or_object</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
300
|
+
<span class='kw'>end</span>
|
301
|
+
<span class='kw'>end</span>
|
302
|
+
<span class='kw'>end</span></pre>
|
303
|
+
</td>
|
304
|
+
</tr>
|
305
|
+
</table>
|
306
|
+
</div>
|
307
|
+
|
308
|
+
<div class="method_details ">
|
309
|
+
<h3 class="signature " id="register_delegators-instance_method">
|
310
|
+
|
311
|
+
- (<tt>Object</tt>) <strong>register_delegators</strong>(*args)
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
</h3><div class="docstring">
|
318
|
+
<div class="discussion">
|
319
|
+
|
320
|
+
<p>Allows to register delegators</p>
|
321
|
+
|
322
|
+
|
323
|
+
</div>
|
324
|
+
</div>
|
325
|
+
<div class="tags">
|
326
|
+
<p class="tag_title">Parameters:</p>
|
327
|
+
<ul class="param">
|
328
|
+
|
329
|
+
<li>
|
330
|
+
|
331
|
+
<span class='name'>args</span>
|
332
|
+
|
333
|
+
|
334
|
+
<span class='type'></span>
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
—
|
339
|
+
<div class='inline'>
|
340
|
+
<p>List of Symbols, the method name that will be delegated.</p>
|
341
|
+
</div>
|
342
|
+
|
343
|
+
</li>
|
344
|
+
|
345
|
+
</ul>
|
346
|
+
|
347
|
+
<p class="tag_title">Returns:</p>
|
348
|
+
<ul class="return">
|
349
|
+
|
350
|
+
<li>
|
351
|
+
|
352
|
+
|
353
|
+
<span class='type'></span>
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
<div class='inline'>
|
359
|
+
<p>Nothing.</p>
|
360
|
+
</div>
|
361
|
+
|
362
|
+
</li>
|
363
|
+
|
364
|
+
</ul>
|
365
|
+
|
366
|
+
</div><table class="source_code">
|
367
|
+
<tr>
|
368
|
+
<td>
|
369
|
+
<pre class="lines">
|
370
|
+
|
371
|
+
|
372
|
+
43
|
373
|
+
44
|
374
|
+
45
|
375
|
+
46
|
376
|
+
47
|
377
|
+
48
|
378
|
+
49
|
379
|
+
50
|
380
|
+
51
|
381
|
+
52
|
382
|
+
53</pre>
|
383
|
+
</td>
|
384
|
+
<td>
|
385
|
+
<pre class="code"><span class="info file"># File 'lib/defered_delegator.rb', line 43</span>
|
386
|
+
|
387
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_register_delegators'>register_delegators</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span>
|
388
|
+
<span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_delegator'>delegator</span><span class='op'>|</span>
|
389
|
+
<span class='id identifier rubyid_delegator'>delegator</span> <span class='op'>=</span> <span class='id identifier rubyid_delegator'>delegator</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
390
|
+
<span class='id identifier rubyid_module_eval'>module_eval</span> <span class='tstring'><span class='tstring_beg'>%Q{</span><span class='tstring_content'>
|
391
|
+
def self.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_delegator'>delegator</span><span class='rbrace'>}</span><span class='tstring_content'> *parameters
|
392
|
+
@delegators ||= []
|
393
|
+
@delegators << { name: :</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_delegator'>delegator</span><span class='rbrace'>}</span><span class='tstring_content'>, params: parameters }
|
394
|
+
end
|
395
|
+
</span><span class='tstring_end'>}</span></span>
|
396
|
+
<span class='kw'>end</span>
|
397
|
+
<span class='kw'>end</span></pre>
|
398
|
+
</td>
|
399
|
+
</tr>
|
400
|
+
</table>
|
401
|
+
</div>
|
402
|
+
|
403
|
+
</div>
|
404
|
+
|
405
|
+
</div>
|
406
|
+
|
407
|
+
<div id="footer">
|
408
|
+
Generated on Thu Feb 21 02:06:16 2013 by
|
409
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
410
|
+
0.8.4.1 (ruby-1.9.3).
|
411
|
+
</div>
|
412
|
+
|
413
|
+
</body>
|
414
|
+
</html>
|