mack-facets 0.6.0.1 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +4 -3
- data/lib/{english_extensions → mack-facets/english_extensions}/inflect.rb +0 -0
- data/lib/{english_extensions → mack-facets/english_extensions}/numerals.rb +0 -0
- data/lib/{extensions → mack-facets/extensions}/array.rb +0 -0
- data/lib/{extensions → mack-facets/extensions}/class.rb +0 -0
- data/lib/{extensions → mack-facets/extensions}/hash.rb +0 -0
- data/lib/{extensions → mack-facets/extensions}/kernel.rb +0 -0
- data/lib/{extensions → mack-facets/extensions}/math.rb +0 -0
- data/lib/{extensions → mack-facets/extensions}/module.rb +0 -0
- data/lib/mack-facets/extensions/nil_class.rb +7 -0
- data/lib/{extensions → mack-facets/extensions}/object.rb +0 -0
- data/lib/{extensions → mack-facets/extensions}/string.rb +0 -0
- data/lib/{extensions → mack-facets/extensions}/symbol.rb +0 -0
- data/lib/{utils → mack-facets/utils}/inflections.rb +0 -0
- data/lib/{utils → mack-facets/utils}/inflector.rb +0 -0
- data/lib/{utils → mack-facets/utils}/options_merger.rb +0 -0
- data/lib/mack-facets/utils/registry_list.rb +83 -0
- data/lib/mack-facets/utils/registry_map.rb +94 -0
- data/lib/mack-facets.rb +11 -8
- metadata +29 -48
- data/doc/classes/Array.html +0 -408
- data/doc/classes/Class.html +0 -233
- data/doc/classes/Hash.html +0 -233
- data/doc/classes/Kernel.html +0 -184
- data/doc/classes/Mack/Utils/Inflector.html +0 -382
- data/doc/classes/Math.html +0 -188
- data/doc/classes/Module.html +0 -203
- data/doc/classes/Object.html +0 -558
- data/doc/classes/String.html +0 -451
- data/doc/classes/Symbol.html +0 -148
- data/doc/created.rid +0 -1
- data/doc/files/README.html +0 -111
- data/doc/files/lib/english_extensions/inflect_rb.html +0 -101
- data/doc/files/lib/english_extensions/numerals_rb.html +0 -101
- data/doc/files/lib/extensions/array_rb.html +0 -101
- data/doc/files/lib/extensions/class_rb.html +0 -101
- data/doc/files/lib/extensions/hash_rb.html +0 -108
- data/doc/files/lib/extensions/kernel_rb.html +0 -109
- data/doc/files/lib/extensions/math_rb.html +0 -101
- data/doc/files/lib/extensions/module_rb.html +0 -101
- data/doc/files/lib/extensions/object_rb.html +0 -101
- data/doc/files/lib/extensions/string_rb.html +0 -101
- data/doc/files/lib/extensions/symbol_rb.html +0 -101
- data/doc/files/lib/mack-facets_rb.html +0 -120
- data/doc/files/lib/utils/inflections_rb.html +0 -101
- data/doc/files/lib/utils/inflector_rb.html +0 -108
- data/doc/files/lib/utils/options_merger_rb.html +0 -101
- data/doc/fr_class_index.html +0 -36
- data/doc/fr_file_index.html +0 -42
- data/doc/fr_method_index.html +0 -75
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -208
data/doc/classes/Hash.html
DELETED
@@ -1,233 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Class: Hash</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">Hash</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../files/lib/extensions/hash_rb.html">
|
59
|
-
lib/extensions/hash.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
<a href="Object.html">
|
69
|
-
Object
|
70
|
-
</a>
|
71
|
-
</td>
|
72
|
-
</tr>
|
73
|
-
</table>
|
74
|
-
</div>
|
75
|
-
<!-- banner header -->
|
76
|
-
|
77
|
-
<div id="bodyContent">
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
<div id="contextContent">
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
</div>
|
86
|
-
|
87
|
-
<div id="method-list">
|
88
|
-
<h3 class="section-bar">Methods</h3>
|
89
|
-
|
90
|
-
<div class="name-list">
|
91
|
-
<a href="#M000003">-</a>
|
92
|
-
<a href="#M000002">join</a>
|
93
|
-
<a href="#M000004">to_params</a>
|
94
|
-
</div>
|
95
|
-
</div>
|
96
|
-
|
97
|
-
</div>
|
98
|
-
|
99
|
-
|
100
|
-
<!-- if includes -->
|
101
|
-
|
102
|
-
<div id="section">
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
<!-- if method_list -->
|
112
|
-
<div id="methods">
|
113
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
114
|
-
|
115
|
-
<div id="method-M000003" class="method-detail">
|
116
|
-
<a name="M000003"></a>
|
117
|
-
|
118
|
-
<div class="method-heading">
|
119
|
-
<a href="#M000003" class="method-signature">
|
120
|
-
<span class="method-name">-</span><span class="method-args">(ars)</span>
|
121
|
-
</a>
|
122
|
-
</div>
|
123
|
-
|
124
|
-
<div class="method-description">
|
125
|
-
<p>
|
126
|
-
Deletes the key(s) passed in from the hash.
|
127
|
-
</p>
|
128
|
-
<p><a class="source-toggle" href="#"
|
129
|
-
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
130
|
-
<div class="method-source-code" id="M000003-source">
|
131
|
-
<pre>
|
132
|
-
<span class="ruby-comment cmt"># File lib/extensions/hash.rb, line 14</span>
|
133
|
-
14: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">-</span>(<span class="ruby-identifier">ars</span>)
|
134
|
-
15: [<span class="ruby-identifier">ars</span>].<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">a</span>)}
|
135
|
-
16: <span class="ruby-keyword kw">self</span>
|
136
|
-
17: <span class="ruby-keyword kw">end</span>
|
137
|
-
</pre>
|
138
|
-
</div>
|
139
|
-
</div>
|
140
|
-
</div>
|
141
|
-
|
142
|
-
<div id="method-M000002" class="method-detail">
|
143
|
-
<a name="M000002"></a>
|
144
|
-
|
145
|
-
<div class="method-heading">
|
146
|
-
<a href="#M000002" class="method-signature">
|
147
|
-
<span class="method-name">join</span><span class="method-args">(pair_string, join_string)</span>
|
148
|
-
</a>
|
149
|
-
</div>
|
150
|
-
|
151
|
-
<div class="method-description">
|
152
|
-
<p><a class="source-toggle" href="#"
|
153
|
-
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
154
|
-
<div class="method-source-code" id="M000002-source">
|
155
|
-
<pre>
|
156
|
-
<span class="ruby-comment cmt"># File lib/extensions/hash.rb, line 4</span>
|
157
|
-
4: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">join</span>(<span class="ruby-identifier">pair_string</span>, <span class="ruby-identifier">join_string</span>)
|
158
|
-
5: <span class="ruby-identifier">output</span> = []
|
159
|
-
6: <span class="ruby-identifier">sorted</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">sort</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">to_s</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">b</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">to_s</span>}
|
160
|
-
7: <span class="ruby-identifier">sorted</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ar</span><span class="ruby-operator">|</span>
|
161
|
-
8: <span class="ruby-identifier">output</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">sprintf</span>(<span class="ruby-identifier">pair_string</span>, <span class="ruby-identifier">ar</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">ar</span>[<span class="ruby-value">1</span>])
|
162
|
-
9: <span class="ruby-keyword kw">end</span>
|
163
|
-
10: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">join_string</span>)
|
164
|
-
11: <span class="ruby-keyword kw">end</span>
|
165
|
-
</pre>
|
166
|
-
</div>
|
167
|
-
</div>
|
168
|
-
</div>
|
169
|
-
|
170
|
-
<div id="method-M000004" class="method-detail">
|
171
|
-
<a name="M000004"></a>
|
172
|
-
|
173
|
-
<div class="method-heading">
|
174
|
-
<a href="#M000004" class="method-signature">
|
175
|
-
<span class="method-name">to_params</span><span class="method-args">(escape = true)</span>
|
176
|
-
</a>
|
177
|
-
</div>
|
178
|
-
|
179
|
-
<div class="method-description">
|
180
|
-
<p>
|
181
|
-
Converts a hash to query string parameters. An optional boolean escapes the
|
182
|
-
values if true, which is the default.
|
183
|
-
</p>
|
184
|
-
<p><a class="source-toggle" href="#"
|
185
|
-
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
186
|
-
<div class="method-source-code" id="M000004-source">
|
187
|
-
<pre>
|
188
|
-
<span class="ruby-comment cmt"># File lib/extensions/hash.rb, line 21</span>
|
189
|
-
21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_params</span>(<span class="ruby-identifier">escape</span> = <span class="ruby-keyword kw">true</span>)
|
190
|
-
22: <span class="ruby-identifier">params</span> = <span class="ruby-value str">''</span>
|
191
|
-
23: <span class="ruby-identifier">stack</span> = []
|
192
|
-
24:
|
193
|
-
25: <span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
194
|
-
26: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
195
|
-
27: <span class="ruby-identifier">stack</span> <span class="ruby-operator"><<</span> [<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span>]
|
196
|
-
28: <span class="ruby-keyword kw">else</span>
|
197
|
-
29: <span class="ruby-identifier">v</span> = <span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">uri_escape</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">escape</span>
|
198
|
-
30: <span class="ruby-identifier">params</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{k}=#{v}&"</span>
|
199
|
-
31: <span class="ruby-keyword kw">end</span>
|
200
|
-
32: <span class="ruby-keyword kw">end</span>
|
201
|
-
33:
|
202
|
-
34: <span class="ruby-identifier">stack</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">parent</span>, <span class="ruby-identifier">hash</span><span class="ruby-operator">|</span>
|
203
|
-
35: <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
204
|
-
36: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
205
|
-
37: <span class="ruby-identifier">stack</span> <span class="ruby-operator"><<</span> [<span class="ruby-node">"#{parent}[#{k}]"</span>, <span class="ruby-identifier">v</span>]
|
206
|
-
38: <span class="ruby-keyword kw">else</span>
|
207
|
-
39: <span class="ruby-identifier">v</span> = <span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">uri_escape</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">escape</span>
|
208
|
-
40: <span class="ruby-identifier">params</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{parent}[#{k}]=#{v}&"</span>
|
209
|
-
41: <span class="ruby-keyword kw">end</span>
|
210
|
-
42: <span class="ruby-keyword kw">end</span>
|
211
|
-
43: <span class="ruby-keyword kw">end</span>
|
212
|
-
44:
|
213
|
-
45: <span class="ruby-identifier">params</span>.<span class="ruby-identifier">chop!</span> <span class="ruby-comment cmt"># trailing &</span>
|
214
|
-
46: <span class="ruby-identifier">params</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">"&"</span>).<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"&"</span>)
|
215
|
-
47: <span class="ruby-keyword kw">end</span>
|
216
|
-
</pre>
|
217
|
-
</div>
|
218
|
-
</div>
|
219
|
-
</div>
|
220
|
-
|
221
|
-
|
222
|
-
</div>
|
223
|
-
|
224
|
-
|
225
|
-
</div>
|
226
|
-
|
227
|
-
|
228
|
-
<div id="validator-badges">
|
229
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
230
|
-
</div>
|
231
|
-
|
232
|
-
</body>
|
233
|
-
</html>
|
data/doc/classes/Kernel.html
DELETED
@@ -1,184 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Module: Kernel</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Module</strong></td>
|
53
|
-
<td class="class-name-in-header">Kernel</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../files/lib/extensions/kernel_rb.html">
|
59
|
-
lib/extensions/kernel.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
</table>
|
66
|
-
</div>
|
67
|
-
<!-- banner header -->
|
68
|
-
|
69
|
-
<div id="bodyContent">
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
<div id="contextContent">
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
</div>
|
78
|
-
|
79
|
-
<div id="method-list">
|
80
|
-
<h3 class="section-bar">Methods</h3>
|
81
|
-
|
82
|
-
<div class="name-list">
|
83
|
-
<a href="#M000045">pp_to_s</a>
|
84
|
-
<a href="#M000046">retryable</a>
|
85
|
-
</div>
|
86
|
-
</div>
|
87
|
-
|
88
|
-
</div>
|
89
|
-
|
90
|
-
|
91
|
-
<!-- if includes -->
|
92
|
-
|
93
|
-
<div id="section">
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
<!-- if method_list -->
|
103
|
-
<div id="methods">
|
104
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
105
|
-
|
106
|
-
<div id="method-M000045" class="method-detail">
|
107
|
-
<a name="M000045"></a>
|
108
|
-
|
109
|
-
<div class="method-heading">
|
110
|
-
<a href="#M000045" class="method-signature">
|
111
|
-
<span class="method-name">pp_to_s</span><span class="method-args">(object)</span>
|
112
|
-
</a>
|
113
|
-
</div>
|
114
|
-
|
115
|
-
<div class="method-description">
|
116
|
-
<p><a class="source-toggle" href="#"
|
117
|
-
onclick="toggleCode('M000045-source');return false;">[Source]</a></p>
|
118
|
-
<div class="method-source-code" id="M000045-source">
|
119
|
-
<pre>
|
120
|
-
<span class="ruby-comment cmt"># File lib/extensions/kernel.rb, line 6</span>
|
121
|
-
6: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pp_to_s</span>(<span class="ruby-identifier">object</span>)
|
122
|
-
7: <span class="ruby-identifier">pp_out</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>
|
123
|
-
8: <span class="ruby-constant">PP</span>.<span class="ruby-identifier">pp</span>(<span class="ruby-identifier">object</span>,<span class="ruby-identifier">pp_out</span>)
|
124
|
-
9: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">pp_out</span>.<span class="ruby-identifier">string</span>
|
125
|
-
10: <span class="ruby-keyword kw">end</span>
|
126
|
-
</pre>
|
127
|
-
</div>
|
128
|
-
</div>
|
129
|
-
</div>
|
130
|
-
|
131
|
-
<div id="method-M000046" class="method-detail">
|
132
|
-
<a name="M000046"></a>
|
133
|
-
|
134
|
-
<div class="method-heading">
|
135
|
-
<a href="#M000046" class="method-signature">
|
136
|
-
<span class="method-name">retryable</span><span class="method-args">(options = {}, &block)</span>
|
137
|
-
</a>
|
138
|
-
</div>
|
139
|
-
|
140
|
-
<div class="method-description">
|
141
|
-
<p><a class="source-toggle" href="#"
|
142
|
-
onclick="toggleCode('M000046-source');return false;">[Source]</a></p>
|
143
|
-
<div class="method-source-code" id="M000046-source">
|
144
|
-
<pre>
|
145
|
-
<span class="ruby-comment cmt"># File lib/extensions/kernel.rb, line 12</span>
|
146
|
-
12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retryable</span>(<span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
147
|
-
13: <span class="ruby-identifier">opts</span> = { <span class="ruby-identifier">:tries</span> =<span class="ruby-operator">></span> <span class="ruby-value">1</span>, <span class="ruby-identifier">:on</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Exception</span> }.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>)
|
148
|
-
14:
|
149
|
-
15: <span class="ruby-identifier">retries</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:tries</span>]
|
150
|
-
16: <span class="ruby-identifier">retry_exceptions</span> = [<span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:on</span>]].<span class="ruby-identifier">flatten</span>
|
151
|
-
17:
|
152
|
-
18: <span class="ruby-identifier">x</span> = <span class="ruby-node">%{
|
153
|
-
19: begin
|
154
|
-
20: return yield
|
155
|
-
21: rescue #{retry_exceptions.join(", ")} => e
|
156
|
-
22: retries -= 1
|
157
|
-
23: if retries > 0
|
158
|
-
24: retry
|
159
|
-
25: else
|
160
|
-
26: raise e
|
161
|
-
27: end
|
162
|
-
28: end
|
163
|
-
29: }</span>
|
164
|
-
30:
|
165
|
-
31: <span class="ruby-identifier">eval</span>(<span class="ruby-identifier">x</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
166
|
-
32: <span class="ruby-keyword kw">end</span>
|
167
|
-
</pre>
|
168
|
-
</div>
|
169
|
-
</div>
|
170
|
-
</div>
|
171
|
-
|
172
|
-
|
173
|
-
</div>
|
174
|
-
|
175
|
-
|
176
|
-
</div>
|
177
|
-
|
178
|
-
|
179
|
-
<div id="validator-badges">
|
180
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
181
|
-
</div>
|
182
|
-
|
183
|
-
</body>
|
184
|
-
</html>
|