mack_ruby_core_extensions 0.1.8 → 0.1.9
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.
- data/lib/extensions/hash.rb +6 -5
- data/test/extensions/hash_test.rb +5 -14
- metadata +3 -38
- data/doc/classes/Array.html +0 -465
- data/doc/classes/Class.html +0 -233
- data/doc/classes/Float.html +0 -148
- data/doc/classes/Hash.html +0 -232
- data/doc/classes/Kernel.html +0 -184
- data/doc/classes/Mack/Utils/Inflector.html +0 -422
- data/doc/classes/Math.html +0 -188
- data/doc/classes/MethodNotImplemented.html +0 -155
- data/doc/classes/Module.html +0 -203
- data/doc/classes/NilClass.html +0 -151
- data/doc/classes/Object.html +0 -448
- data/doc/classes/String.html +0 -977
- data/doc/classes/Symbol.html +0 -148
- data/doc/created.rid +0 -1
- data/doc/files/README.html +0 -151
- 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/float_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/method_not_implemented_rb.html +0 -108
- data/doc/files/lib/extensions/module_rb.html +0 -101
- data/doc/files/lib/extensions/nil_rb.html +0 -101
- data/doc/files/lib/extensions/object_rb.html +0 -101
- data/doc/files/lib/extensions/string_rb.html +0 -108
- data/doc/files/lib/extensions/symbol_rb.html +0 -101
- data/doc/files/lib/mack_ruby_core_extensions_rb.html +0 -101
- data/doc/files/lib/utils/inflections_rb.html +0 -101
- data/doc/files/lib/utils/inflector_rb.html +0 -108
- data/doc/fr_class_index.html +0 -39
- data/doc/fr_file_index.html +0 -42
- data/doc/fr_method_index.html +0 -96
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -208
data/doc/classes/NilClass.html
DELETED
@@ -1,151 +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: NilClass</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">NilClass</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../files/lib/extensions/nil_rb.html">
|
59
|
-
lib/extensions/nil.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="#M000023">blank?</a>
|
92
|
-
</div>
|
93
|
-
</div>
|
94
|
-
|
95
|
-
</div>
|
96
|
-
|
97
|
-
|
98
|
-
<!-- if includes -->
|
99
|
-
|
100
|
-
<div id="section">
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
<!-- if method_list -->
|
110
|
-
<div id="methods">
|
111
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
112
|
-
|
113
|
-
<div id="method-M000023" class="method-detail">
|
114
|
-
<a name="M000023"></a>
|
115
|
-
|
116
|
-
<div class="method-heading">
|
117
|
-
<a href="#M000023" class="method-signature">
|
118
|
-
<span class="method-name">blank?</span><span class="method-args">()</span>
|
119
|
-
</a>
|
120
|
-
</div>
|
121
|
-
|
122
|
-
<div class="method-description">
|
123
|
-
<p>
|
124
|
-
Will always allow true since nil‘s are well, nils.
|
125
|
-
</p>
|
126
|
-
<p><a class="source-toggle" href="#"
|
127
|
-
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
128
|
-
<div class="method-source-code" id="M000023-source">
|
129
|
-
<pre>
|
130
|
-
<span class="ruby-comment cmt"># File lib/extensions/nil.rb, line 4</span>
|
131
|
-
4: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">blank?</span>
|
132
|
-
5: <span class="ruby-keyword kw">true</span>
|
133
|
-
6: <span class="ruby-keyword kw">end</span>
|
134
|
-
</pre>
|
135
|
-
</div>
|
136
|
-
</div>
|
137
|
-
</div>
|
138
|
-
|
139
|
-
|
140
|
-
</div>
|
141
|
-
|
142
|
-
|
143
|
-
</div>
|
144
|
-
|
145
|
-
|
146
|
-
<div id="validator-badges">
|
147
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
148
|
-
</div>
|
149
|
-
|
150
|
-
</body>
|
151
|
-
</html>
|
data/doc/classes/Object.html
DELETED
@@ -1,448 +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: Object</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">Object</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../files/lib/extensions/object_rb.html">
|
59
|
-
lib/extensions/object.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="#M000024">class_parents</a>
|
92
|
-
<a href="#M000029">ivar_cache</a>
|
93
|
-
<a href="#M000030">ivar_cache_clear</a>
|
94
|
-
<a href="#M000031">namespaces</a>
|
95
|
-
<a href="#M000026">needs_method</a>
|
96
|
-
<a href="#M000027">running_time</a>
|
97
|
-
<a href="#M000028">send_with_chain</a>
|
98
|
-
<a href="#M000025">to_param</a>
|
99
|
-
</div>
|
100
|
-
</div>
|
101
|
-
|
102
|
-
</div>
|
103
|
-
|
104
|
-
|
105
|
-
<!-- if includes -->
|
106
|
-
|
107
|
-
<div id="section">
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
<!-- if method_list -->
|
117
|
-
<div id="methods">
|
118
|
-
<h3 class="section-bar">Public Class methods</h3>
|
119
|
-
|
120
|
-
<div id="method-M000026" class="method-detail">
|
121
|
-
<a name="M000026"></a>
|
122
|
-
|
123
|
-
<div class="method-heading">
|
124
|
-
<a href="#M000026" class="method-signature">
|
125
|
-
<span class="method-name">needs_method</span><span class="method-args">(meth)</span>
|
126
|
-
</a>
|
127
|
-
</div>
|
128
|
-
|
129
|
-
<div class="method-description">
|
130
|
-
<p>
|
131
|
-
Uses <tt>define_method</tt> to create an empty for the method parameter
|
132
|
-
defined. That method will then raise <a
|
133
|
-
href="MethodNotImplemented.html">MethodNotImplemented</a>. This is useful
|
134
|
-
for creating interfaces and you want to stub out methods that others need
|
135
|
-
to implement.
|
136
|
-
</p>
|
137
|
-
<p><a class="source-toggle" href="#"
|
138
|
-
onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
|
139
|
-
<div class="method-source-code" id="M000026-source">
|
140
|
-
<pre>
|
141
|
-
<span class="ruby-comment cmt"># File lib/extensions/object.rb, line 17</span>
|
142
|
-
17: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">needs_method</span>(<span class="ruby-identifier">meth</span>)
|
143
|
-
18: <span class="ruby-identifier">define_method</span>(<span class="ruby-identifier">meth</span>) <span class="ruby-keyword kw">do</span>
|
144
|
-
19: <span class="ruby-identifier">raise</span> <span class="ruby-constant">MethodNotImplemented</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">meth</span>)
|
145
|
-
20: <span class="ruby-keyword kw">end</span>
|
146
|
-
21: <span class="ruby-keyword kw">end</span>
|
147
|
-
</pre>
|
148
|
-
</div>
|
149
|
-
</div>
|
150
|
-
</div>
|
151
|
-
|
152
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
153
|
-
|
154
|
-
<div id="method-M000024" class="method-detail">
|
155
|
-
<a name="M000024"></a>
|
156
|
-
|
157
|
-
<div class="method-heading">
|
158
|
-
<a href="#M000024" class="method-signature">
|
159
|
-
<span class="method-name">class_parents</span><span class="method-args">()</span>
|
160
|
-
</a>
|
161
|
-
</div>
|
162
|
-
|
163
|
-
<div class="method-description">
|
164
|
-
<p>
|
165
|
-
See <a href="Class.html">Class</a> parents for more information.
|
166
|
-
</p>
|
167
|
-
<p><a class="source-toggle" href="#"
|
168
|
-
onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
|
169
|
-
<div class="method-source-code" id="M000024-source">
|
170
|
-
<pre>
|
171
|
-
<span class="ruby-comment cmt"># File lib/extensions/object.rb, line 4</span>
|
172
|
-
4: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">class_parents</span>
|
173
|
-
5: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">parents</span>
|
174
|
-
6: <span class="ruby-keyword kw">end</span>
|
175
|
-
</pre>
|
176
|
-
</div>
|
177
|
-
</div>
|
178
|
-
</div>
|
179
|
-
|
180
|
-
<div id="method-M000029" class="method-detail">
|
181
|
-
<a name="M000029"></a>
|
182
|
-
|
183
|
-
<div class="method-heading">
|
184
|
-
<a href="#M000029" class="method-signature">
|
185
|
-
<span class="method-name">ivar_cache</span><span class="method-args">(var_name = nil) {|| ...}</span>
|
186
|
-
</a>
|
187
|
-
</div>
|
188
|
-
|
189
|
-
<div class="method-description">
|
190
|
-
<p>
|
191
|
-
<a href="Object.html#M000029">ivar_cache</a> allows you to cache the
|
192
|
-
results of the block into an instance variable in a class, and then will
|
193
|
-
serve up that instance variable the next time you call that method again.
|
194
|
-
</p>
|
195
|
-
<p>
|
196
|
-
old way:
|
197
|
-
</p>
|
198
|
-
<pre>
|
199
|
-
def show_page_link
|
200
|
-
unless @show_page_link # check if instance variable exists
|
201
|
-
# if the instance variable doesn't exist let's do some work and assign it to the instance variable.
|
202
|
-
@show_page_link = link_to("show", some_url(:id => self.id, :foo => bar, etc... => etc))
|
203
|
-
end
|
204
|
-
@show_page_link # now return the instance variable
|
205
|
-
end
|
206
|
-
</pre>
|
207
|
-
<p>
|
208
|
-
new way:
|
209
|
-
</p>
|
210
|
-
<pre>
|
211
|
-
def show_page_link
|
212
|
-
ivar_cache do
|
213
|
-
link_to("show", some_url(:id => self.id, :foo => bar, etc... => etc))
|
214
|
-
end
|
215
|
-
end
|
216
|
-
</pre>
|
217
|
-
<p>
|
218
|
-
this does everything the old way did, but it is much cleaner, and a lot
|
219
|
-
less code! in case you‘re wondering it caches the result, by default,
|
220
|
-
to an instance variable named after the method, so in our above example the
|
221
|
-
instance variable would be name, <tt>@show_page_link</tt>. this can be
|
222
|
-
overridden like such:
|
223
|
-
</p>
|
224
|
-
<pre>
|
225
|
-
def show_page_link
|
226
|
-
ivar_cache("foo_var") do
|
227
|
-
link_to("show", some_url(:id => self.id, :foo => bar, etc... => etc))
|
228
|
-
end
|
229
|
-
end
|
230
|
-
</pre>
|
231
|
-
<p>
|
232
|
-
now it will cache it to <tt>@foo_var</tt>
|
233
|
-
</p>
|
234
|
-
<p><a class="source-toggle" href="#"
|
235
|
-
onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
|
236
|
-
<div class="method-source-code" id="M000029-source">
|
237
|
-
<pre>
|
238
|
-
<span class="ruby-comment cmt"># File lib/extensions/object.rb, line 90</span>
|
239
|
-
90: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ivar_cache</span>(<span class="ruby-identifier">var_name</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
240
|
-
91: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">var_name</span>.<span class="ruby-identifier">nil?</span>
|
241
|
-
92: <span class="ruby-identifier">call</span> = <span class="ruby-identifier">caller</span>[<span class="ruby-value">0</span>]
|
242
|
-
93: <span class="ruby-identifier">var_name</span> = <span class="ruby-identifier">call</span>[(<span class="ruby-identifier">call</span>.<span class="ruby-identifier">index</span>(<span class="ruby-value str">'`'</span>)<span class="ruby-operator">+</span><span class="ruby-value">1</span>)<span class="ruby-operator">...</span><span class="ruby-identifier">call</span>.<span class="ruby-identifier">index</span>(<span class="ruby-value str">"'"</span>)]
|
243
|
-
94: <span class="ruby-keyword kw">end</span>
|
244
|
-
95: <span class="ruby-identifier">var</span> = <span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-node">"@#{var_name}"</span>)
|
245
|
-
96: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">var</span>
|
246
|
-
97: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-node">"@#{var_name}"</span>, <span class="ruby-keyword kw">yield</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
247
|
-
98: <span class="ruby-keyword kw">end</span>
|
248
|
-
99: <span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-node">"@#{var_name}"</span>)
|
249
|
-
100: <span class="ruby-keyword kw">end</span>
|
250
|
-
</pre>
|
251
|
-
</div>
|
252
|
-
</div>
|
253
|
-
</div>
|
254
|
-
|
255
|
-
<div id="method-M000030" class="method-detail">
|
256
|
-
<a name="M000030"></a>
|
257
|
-
|
258
|
-
<div class="method-heading">
|
259
|
-
<a href="#M000030" class="method-signature">
|
260
|
-
<span class="method-name">ivar_cache_clear</span><span class="method-args">(var_name = nil) {|if block_given?| ...}</span>
|
261
|
-
</a>
|
262
|
-
</div>
|
263
|
-
|
264
|
-
<div class="method-description">
|
265
|
-
<p><a class="source-toggle" href="#"
|
266
|
-
onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
|
267
|
-
<div class="method-source-code" id="M000030-source">
|
268
|
-
<pre>
|
269
|
-
<span class="ruby-comment cmt"># File lib/extensions/object.rb, line 102</span>
|
270
|
-
102: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ivar_cache_clear</span>(<span class="ruby-identifier">var_name</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
271
|
-
103: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">var_name</span>.<span class="ruby-identifier">nil?</span>
|
272
|
-
104: <span class="ruby-identifier">call</span> = <span class="ruby-identifier">caller</span>[<span class="ruby-value">0</span>]
|
273
|
-
105: <span class="ruby-identifier">var_name</span> = <span class="ruby-identifier">call</span>[(<span class="ruby-identifier">call</span>.<span class="ruby-identifier">index</span>(<span class="ruby-value str">'`'</span>)<span class="ruby-operator">+</span><span class="ruby-value">1</span>)<span class="ruby-operator">...</span><span class="ruby-identifier">call</span>.<span class="ruby-identifier">index</span>(<span class="ruby-value str">"'"</span>)]
|
274
|
-
106: <span class="ruby-keyword kw">end</span>
|
275
|
-
107: <span class="ruby-identifier">remove_instance_variable</span>(<span class="ruby-node">"@#{var_name}"</span>) <span class="ruby-comment cmt">#rescue</span>
|
276
|
-
108: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
277
|
-
109: <span class="ruby-keyword kw">end</span>
|
278
|
-
</pre>
|
279
|
-
</div>
|
280
|
-
</div>
|
281
|
-
</div>
|
282
|
-
|
283
|
-
<div id="method-M000031" class="method-detail">
|
284
|
-
<a name="M000031"></a>
|
285
|
-
|
286
|
-
<div class="method-heading">
|
287
|
-
<a href="#M000031" class="method-signature">
|
288
|
-
<span class="method-name">namespaces</span><span class="method-args">()</span>
|
289
|
-
</a>
|
290
|
-
</div>
|
291
|
-
|
292
|
-
<div class="method-description">
|
293
|
-
<p>
|
294
|
-
Returns the <a href="Object.html#M000031">namespaces</a> for a particular
|
295
|
-
object.
|
296
|
-
</p>
|
297
|
-
<p>
|
298
|
-
Examples:
|
299
|
-
</p>
|
300
|
-
<pre>
|
301
|
-
Animals::Dog::Poodle.new.namespaces # => ["Animals", "Dog"]
|
302
|
-
</pre>
|
303
|
-
<p><a class="source-toggle" href="#"
|
304
|
-
onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
|
305
|
-
<div class="method-source-code" id="M000031-source">
|
306
|
-
<pre>
|
307
|
-
<span class="ruby-comment cmt"># File lib/extensions/object.rb, line 115</span>
|
308
|
-
115: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">namespaces</span>
|
309
|
-
116: <span class="ruby-identifier">ivar_cache</span>(<span class="ruby-value str">"object_namespaces"</span>) <span class="ruby-keyword kw">do</span>
|
310
|
-
117: <span class="ruby-identifier">nss</span> = []
|
311
|
-
118: <span class="ruby-identifier">full_name</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>
|
312
|
-
119: <span class="ruby-identifier">nss</span> = <span class="ruby-identifier">full_name</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">"::"</span>)
|
313
|
-
120: <span class="ruby-identifier">nss</span>.<span class="ruby-identifier">pop</span>
|
314
|
-
121: <span class="ruby-identifier">nss</span>
|
315
|
-
122: <span class="ruby-keyword kw">end</span>
|
316
|
-
123: <span class="ruby-keyword kw">end</span>
|
317
|
-
</pre>
|
318
|
-
</div>
|
319
|
-
</div>
|
320
|
-
</div>
|
321
|
-
|
322
|
-
<div id="method-M000027" class="method-detail">
|
323
|
-
<a name="M000027"></a>
|
324
|
-
|
325
|
-
<div class="method-heading">
|
326
|
-
<a href="#M000027" class="method-signature">
|
327
|
-
<span class="method-name">running_time</span><span class="method-args">(message = "", logger = nil) {|if block_given?| ...}</span>
|
328
|
-
</a>
|
329
|
-
</div>
|
330
|
-
|
331
|
-
<div class="method-description">
|
332
|
-
<p>
|
333
|
-
This prints out running time for the block provided. This is great for
|
334
|
-
things like Rake tasks, etc… where you would like to know how long
|
335
|
-
it, or a section of it took to run.
|
336
|
-
</p>
|
337
|
-
<p><a class="source-toggle" href="#"
|
338
|
-
onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
|
339
|
-
<div class="method-source-code" id="M000027-source">
|
340
|
-
<pre>
|
341
|
-
<span class="ruby-comment cmt"># File lib/extensions/object.rb, line 26</span>
|
342
|
-
26: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">running_time</span>(<span class="ruby-identifier">message</span> = <span class="ruby-value str">""</span>, <span class="ruby-identifier">logger</span> = <span class="ruby-keyword kw">nil</span>)
|
343
|
-
27: <span class="ruby-identifier">s_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
344
|
-
28: <span class="ruby-identifier">s</span> = <span class="ruby-node">"---Starting at #{s_time}---"</span>
|
345
|
-
29: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">s</span>
|
346
|
-
30: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-identifier">s</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">nil?</span>
|
347
|
-
31: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
348
|
-
32: <span class="ruby-identifier">e_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
349
|
-
33: <span class="ruby-identifier">e</span> = <span class="ruby-node">"---Ending at #{e_time}---"</span>
|
350
|
-
34: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">e</span>
|
351
|
-
35: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-identifier">e</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">nil?</span>
|
352
|
-
36: <span class="ruby-identifier">secs</span> = <span class="ruby-identifier">e_time</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">s_time</span>
|
353
|
-
37: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">secs</span> <span class="ruby-operator"><</span> <span class="ruby-value">60</span>
|
354
|
-
38: <span class="ruby-identifier">x</span> = <span class="ruby-node">"Running time #{secs} seconds."</span>
|
355
|
-
39: <span class="ruby-keyword kw">else</span>
|
356
|
-
40: <span class="ruby-identifier">x</span> = <span class="ruby-node">"Running time roughly #{secs/60} minutes [#{secs} seconds]"</span>
|
357
|
-
41: <span class="ruby-keyword kw">end</span>
|
358
|
-
42: <span class="ruby-identifier">x</span> <span class="ruby-operator">+=</span> <span class="ruby-node">" [MESSAGE]: #{message}"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">message</span>.<span class="ruby-identifier">blank?</span>
|
359
|
-
43: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">x</span>
|
360
|
-
44: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-identifier">x</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">nil?</span>
|
361
|
-
45: <span class="ruby-keyword kw">end</span>
|
362
|
-
</pre>
|
363
|
-
</div>
|
364
|
-
</div>
|
365
|
-
</div>
|
366
|
-
|
367
|
-
<div id="method-M000028" class="method-detail">
|
368
|
-
<a name="M000028"></a>
|
369
|
-
|
370
|
-
<div class="method-heading">
|
371
|
-
<a href="#M000028" class="method-signature">
|
372
|
-
<span class="method-name">send_with_chain</span><span class="method-args">(methods, *args)</span>
|
373
|
-
</a>
|
374
|
-
</div>
|
375
|
-
|
376
|
-
<div class="method-description">
|
377
|
-
<p>
|
378
|
-
This method will call send to all the methods defined on the previous
|
379
|
-
method.
|
380
|
-
</p>
|
381
|
-
<p>
|
382
|
-
Example:
|
383
|
-
</p>
|
384
|
-
<pre>
|
385
|
-
Fruit.send_with_chain([:new, :get_citrus, :get_orange, :class]) # => Orange
|
386
|
-
</pre>
|
387
|
-
<p>
|
388
|
-
This would be the equivalent:
|
389
|
-
</p>
|
390
|
-
<pre>
|
391
|
-
Fruit.new.get_citrus.get_orange.class
|
392
|
-
</pre>
|
393
|
-
<p><a class="source-toggle" href="#"
|
394
|
-
onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
|
395
|
-
<div class="method-source-code" id="M000028-source">
|
396
|
-
<pre>
|
397
|
-
<span class="ruby-comment cmt"># File lib/extensions/object.rb, line 54</span>
|
398
|
-
54: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_with_chain</span>(<span class="ruby-identifier">methods</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
399
|
-
55: <span class="ruby-identifier">obj</span> = <span class="ruby-keyword kw">self</span>
|
400
|
-
56: [<span class="ruby-identifier">methods</span>].<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span> <span class="ruby-identifier">obj</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">m</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)}
|
401
|
-
57: <span class="ruby-identifier">obj</span>
|
402
|
-
58: <span class="ruby-keyword kw">end</span>
|
403
|
-
</pre>
|
404
|
-
</div>
|
405
|
-
</div>
|
406
|
-
</div>
|
407
|
-
|
408
|
-
<div id="method-M000025" class="method-detail">
|
409
|
-
<a name="M000025"></a>
|
410
|
-
|
411
|
-
<div class="method-heading">
|
412
|
-
<a href="#M000025" class="method-signature">
|
413
|
-
<span class="method-name">to_param</span><span class="method-args">()</span>
|
414
|
-
</a>
|
415
|
-
</div>
|
416
|
-
|
417
|
-
<div class="method-description">
|
418
|
-
<p>
|
419
|
-
This method gets called when a parameter is passed into a named route. This
|
420
|
-
can be overridden in an <a href="Object.html">Object</a> to provlde custom
|
421
|
-
handling of parameters.
|
422
|
-
</p>
|
423
|
-
<p><a class="source-toggle" href="#"
|
424
|
-
onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
|
425
|
-
<div class="method-source-code" id="M000025-source">
|
426
|
-
<pre>
|
427
|
-
<span class="ruby-comment cmt"># File lib/extensions/object.rb, line 10</span>
|
428
|
-
10: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_param</span>
|
429
|
-
11: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>
|
430
|
-
12: <span class="ruby-keyword kw">end</span>
|
431
|
-
</pre>
|
432
|
-
</div>
|
433
|
-
</div>
|
434
|
-
</div>
|
435
|
-
|
436
|
-
|
437
|
-
</div>
|
438
|
-
|
439
|
-
|
440
|
-
</div>
|
441
|
-
|
442
|
-
|
443
|
-
<div id="validator-badges">
|
444
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
445
|
-
</div>
|
446
|
-
|
447
|
-
</body>
|
448
|
-
</html>
|