mack-facets 0.7.1 → 0.7.1.1
Sign up to get free protection for your applications and to get access to all the features.
- metadata +2 -47
- 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 -212
- data/doc/classes/Mack/Facets/DateTime.html +0 -168
- data/doc/classes/Mack/Facets.html +0 -111
- data/doc/classes/Mack/Utils/BlankSlate.html +0 -113
- data/doc/classes/Mack/Utils/Inflector.html +0 -382
- data/doc/classes/Mack/Utils/RegistryList.html +0 -469
- data/doc/classes/Mack/Utils/RegistryMap.html +0 -479
- data/doc/classes/Math.html +0 -188
- data/doc/classes/Module.html +0 -203
- data/doc/classes/NilClass.html +0 -148
- data/doc/classes/Object.html +0 -558
- data/doc/classes/String.html +0 -464
- data/doc/classes/Symbol.html +0 -148
- data/doc/classes/Time.html +0 -204
- data/doc/created.rid +0 -1
- data/doc/files/README.html +0 -112
- data/doc/files/lib/mack-facets/english_extensions/inflect_rb.html +0 -101
- data/doc/files/lib/mack-facets/english_extensions/numerals_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/array_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/class_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/date_time_rb.html +0 -129
- data/doc/files/lib/mack-facets/extensions/hash_rb.html +0 -108
- data/doc/files/lib/mack-facets/extensions/kernel_rb.html +0 -109
- data/doc/files/lib/mack-facets/extensions/math_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/module_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/nil_class_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/object_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/string_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/symbol_rb.html +0 -101
- data/doc/files/lib/mack-facets/extensions/time_rb.html +0 -108
- data/doc/files/lib/mack-facets/utils/blank_slate_rb.html +0 -101
- data/doc/files/lib/mack-facets/utils/inflections_rb.html +0 -101
- data/doc/files/lib/mack-facets/utils/inflector_rb.html +0 -108
- data/doc/files/lib/mack-facets/utils/options_merger_rb.html +0 -101
- data/doc/files/lib/mack-facets/utils/registry_list_rb.html +0 -108
- data/doc/files/lib/mack-facets/utils/registry_map_rb.html +0 -108
- data/doc/files/lib/mack-facets_rb.html +0 -124
- data/doc/fr_class_index.html +0 -43
- data/doc/fr_file_index.html +0 -48
- data/doc/fr_method_index.html +0 -104
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -208
data/doc/classes/Object.html
DELETED
@@ -1,558 +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/mack-facets/extensions/object_rb.html">
|
59
|
-
lib/mack-facets/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="#M000004">class_parents</a>
|
92
|
-
<a href="#M000009">ivar_cache</a>
|
93
|
-
<a href="#M000010">ivar_cache_clear</a>
|
94
|
-
<a href="#M000011">namespaces</a>
|
95
|
-
<a href="#M000006">needs_method</a>
|
96
|
-
<a href="#M000002">print_methods</a>
|
97
|
-
<a href="#M000007">running_time</a>
|
98
|
-
<a href="#M000001">safely_include_module</a>
|
99
|
-
<a href="#M000008">send_with_chain</a>
|
100
|
-
<a href="#M000005">to_param</a>
|
101
|
-
<a href="#M000003">with_options</a>
|
102
|
-
</div>
|
103
|
-
</div>
|
104
|
-
|
105
|
-
</div>
|
106
|
-
|
107
|
-
|
108
|
-
<!-- if includes -->
|
109
|
-
|
110
|
-
<div id="section">
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
<!-- if method_list -->
|
120
|
-
<div id="methods">
|
121
|
-
<h3 class="section-bar">Public Class methods</h3>
|
122
|
-
|
123
|
-
<div id="method-M000006" class="method-detail">
|
124
|
-
<a name="M000006"></a>
|
125
|
-
|
126
|
-
<div class="method-heading">
|
127
|
-
<a href="#M000006" class="method-signature">
|
128
|
-
<span class="method-name">needs_method</span><span class="method-args">(meth)</span>
|
129
|
-
</a>
|
130
|
-
</div>
|
131
|
-
|
132
|
-
<div class="method-description">
|
133
|
-
<p>
|
134
|
-
Uses <tt>define_method</tt> to create an empty for the method parameter
|
135
|
-
defined. That method will then raise MethodNotImplemented. This is useful
|
136
|
-
for creating interfaces and you want to stub out methods that others need
|
137
|
-
to implement.
|
138
|
-
</p>
|
139
|
-
<p><a class="source-toggle" href="#"
|
140
|
-
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
141
|
-
<div class="method-source-code" id="M000006-source">
|
142
|
-
<pre>
|
143
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/object.rb, line 56</span>
|
144
|
-
56: <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>)
|
145
|
-
57: <span class="ruby-identifier">define_method</span>(<span class="ruby-identifier">meth</span>) <span class="ruby-keyword kw">do</span>
|
146
|
-
58: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoMethodError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"The interface you are using requires you define the following method '#{meth}'"</span>)
|
147
|
-
59: <span class="ruby-keyword kw">end</span>
|
148
|
-
60: <span class="ruby-keyword kw">end</span>
|
149
|
-
</pre>
|
150
|
-
</div>
|
151
|
-
</div>
|
152
|
-
</div>
|
153
|
-
|
154
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
155
|
-
|
156
|
-
<div id="method-M000004" class="method-detail">
|
157
|
-
<a name="M000004"></a>
|
158
|
-
|
159
|
-
<div class="method-heading">
|
160
|
-
<a href="#M000004" class="method-signature">
|
161
|
-
<span class="method-name">class_parents</span><span class="method-args">()</span>
|
162
|
-
</a>
|
163
|
-
</div>
|
164
|
-
|
165
|
-
<div class="method-description">
|
166
|
-
<p>
|
167
|
-
See <a href="Class.html">Class</a> parents for more information.
|
168
|
-
</p>
|
169
|
-
<p><a class="source-toggle" href="#"
|
170
|
-
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
171
|
-
<div class="method-source-code" id="M000004-source">
|
172
|
-
<pre>
|
173
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/object.rb, line 43</span>
|
174
|
-
43: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">class_parents</span>
|
175
|
-
44: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">parents</span>
|
176
|
-
45: <span class="ruby-keyword kw">end</span>
|
177
|
-
</pre>
|
178
|
-
</div>
|
179
|
-
</div>
|
180
|
-
</div>
|
181
|
-
|
182
|
-
<div id="method-M000009" class="method-detail">
|
183
|
-
<a name="M000009"></a>
|
184
|
-
|
185
|
-
<div class="method-heading">
|
186
|
-
<a href="#M000009" class="method-signature">
|
187
|
-
<span class="method-name">ivar_cache</span><span class="method-args">(var_name = nil) {|| ...}</span>
|
188
|
-
</a>
|
189
|
-
</div>
|
190
|
-
|
191
|
-
<div class="method-description">
|
192
|
-
<p>
|
193
|
-
<a href="Object.html#M000009">ivar_cache</a> allows you to cache the
|
194
|
-
results of the block into an instance variable in a class, and then will
|
195
|
-
serve up that instance variable the next time you call that method again.
|
196
|
-
</p>
|
197
|
-
<p>
|
198
|
-
old way:
|
199
|
-
</p>
|
200
|
-
<pre>
|
201
|
-
def show_page_link
|
202
|
-
unless @show_page_link # check if instance variable exists
|
203
|
-
# if the instance variable doesn't exist let's do some work and assign it to the instance variable.
|
204
|
-
@show_page_link = link_to("show", some_url(:id => self.id, :foo => bar, etc... => etc))
|
205
|
-
end
|
206
|
-
@show_page_link # now return the instance variable
|
207
|
-
end
|
208
|
-
</pre>
|
209
|
-
<p>
|
210
|
-
new way:
|
211
|
-
</p>
|
212
|
-
<pre>
|
213
|
-
def show_page_link
|
214
|
-
ivar_cache do
|
215
|
-
link_to("show", some_url(:id => self.id, :foo => bar, etc... => etc))
|
216
|
-
end
|
217
|
-
end
|
218
|
-
</pre>
|
219
|
-
<p>
|
220
|
-
this does everything the old way did, but it is much cleaner, and a lot
|
221
|
-
less code! in case you‘re wondering it caches the result, by default,
|
222
|
-
to an instance variable named after the method, so in our above example the
|
223
|
-
instance variable would be name, <tt>@show_page_link</tt>. this can be
|
224
|
-
overridden like such:
|
225
|
-
</p>
|
226
|
-
<pre>
|
227
|
-
def show_page_link
|
228
|
-
ivar_cache("foo_var") do
|
229
|
-
link_to("show", some_url(:id => self.id, :foo => bar, etc... => etc))
|
230
|
-
end
|
231
|
-
end
|
232
|
-
</pre>
|
233
|
-
<p>
|
234
|
-
now it will cache it to <tt>@foo_var</tt>
|
235
|
-
</p>
|
236
|
-
<p><a class="source-toggle" href="#"
|
237
|
-
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
238
|
-
<div class="method-source-code" id="M000009-source">
|
239
|
-
<pre>
|
240
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/object.rb, line 129</span>
|
241
|
-
129: <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>)
|
242
|
-
130: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">var_name</span>.<span class="ruby-identifier">nil?</span>
|
243
|
-
131: <span class="ruby-identifier">call</span> = <span class="ruby-identifier">caller</span>[<span class="ruby-value">0</span>]
|
244
|
-
132: <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>)]
|
245
|
-
133: <span class="ruby-keyword kw">end</span>
|
246
|
-
134: <span class="ruby-identifier">var</span> = <span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-node">"@#{var_name}"</span>)
|
247
|
-
135: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">var</span>
|
248
|
-
136: <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>
|
249
|
-
137: <span class="ruby-keyword kw">end</span>
|
250
|
-
138: <span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-node">"@#{var_name}"</span>)
|
251
|
-
139: <span class="ruby-keyword kw">end</span>
|
252
|
-
</pre>
|
253
|
-
</div>
|
254
|
-
</div>
|
255
|
-
</div>
|
256
|
-
|
257
|
-
<div id="method-M000010" class="method-detail">
|
258
|
-
<a name="M000010"></a>
|
259
|
-
|
260
|
-
<div class="method-heading">
|
261
|
-
<a href="#M000010" class="method-signature">
|
262
|
-
<span class="method-name">ivar_cache_clear</span><span class="method-args">(var_name = nil) {|if block_given?| ...}</span>
|
263
|
-
</a>
|
264
|
-
</div>
|
265
|
-
|
266
|
-
<div class="method-description">
|
267
|
-
<p><a class="source-toggle" href="#"
|
268
|
-
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
269
|
-
<div class="method-source-code" id="M000010-source">
|
270
|
-
<pre>
|
271
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/object.rb, line 141</span>
|
272
|
-
141: <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>)
|
273
|
-
142: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">var_name</span>.<span class="ruby-identifier">nil?</span>
|
274
|
-
143: <span class="ruby-identifier">call</span> = <span class="ruby-identifier">caller</span>[<span class="ruby-value">0</span>]
|
275
|
-
144: <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>)]
|
276
|
-
145: <span class="ruby-keyword kw">end</span>
|
277
|
-
146: <span class="ruby-identifier">remove_instance_variable</span>(<span class="ruby-node">"@#{var_name}"</span>) <span class="ruby-comment cmt">#rescue</span>
|
278
|
-
147: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
279
|
-
148: <span class="ruby-keyword kw">end</span>
|
280
|
-
</pre>
|
281
|
-
</div>
|
282
|
-
</div>
|
283
|
-
</div>
|
284
|
-
|
285
|
-
<div id="method-M000011" class="method-detail">
|
286
|
-
<a name="M000011"></a>
|
287
|
-
|
288
|
-
<div class="method-heading">
|
289
|
-
<a href="#M000011" class="method-signature">
|
290
|
-
<span class="method-name">namespaces</span><span class="method-args">()</span>
|
291
|
-
</a>
|
292
|
-
</div>
|
293
|
-
|
294
|
-
<div class="method-description">
|
295
|
-
<p>
|
296
|
-
Returns the <a href="Object.html#M000011">namespaces</a> for a particular
|
297
|
-
object.
|
298
|
-
</p>
|
299
|
-
<p>
|
300
|
-
Examples:
|
301
|
-
</p>
|
302
|
-
<pre>
|
303
|
-
Animals::Dog::Poodle.new.namespaces # => ["Animals", "Dog"]
|
304
|
-
</pre>
|
305
|
-
<p><a class="source-toggle" href="#"
|
306
|
-
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
307
|
-
<div class="method-source-code" id="M000011-source">
|
308
|
-
<pre>
|
309
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/object.rb, line 154</span>
|
310
|
-
154: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">namespaces</span>
|
311
|
-
155: <span class="ruby-identifier">ivar_cache</span>(<span class="ruby-value str">"object_namespaces"</span>) <span class="ruby-keyword kw">do</span>
|
312
|
-
156: <span class="ruby-identifier">nss</span> = []
|
313
|
-
157: <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>
|
314
|
-
158: <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>)
|
315
|
-
159: <span class="ruby-identifier">nss</span>.<span class="ruby-identifier">pop</span>
|
316
|
-
160: <span class="ruby-identifier">nss</span>
|
317
|
-
161: <span class="ruby-keyword kw">end</span>
|
318
|
-
162: <span class="ruby-keyword kw">end</span>
|
319
|
-
</pre>
|
320
|
-
</div>
|
321
|
-
</div>
|
322
|
-
</div>
|
323
|
-
|
324
|
-
<div id="method-M000002" class="method-detail">
|
325
|
-
<a name="M000002"></a>
|
326
|
-
|
327
|
-
<div class="method-heading">
|
328
|
-
<a href="#M000002" class="method-signature">
|
329
|
-
<span class="method-name">print_methods</span><span class="method-args">()</span>
|
330
|
-
</a>
|
331
|
-
</div>
|
332
|
-
|
333
|
-
<div class="method-description">
|
334
|
-
<p>
|
335
|
-
Prints out the methods associated with this object in alphabetical order.
|
336
|
-
</p>
|
337
|
-
<p><a class="source-toggle" href="#"
|
338
|
-
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
339
|
-
<div class="method-source-code" id="M000002-source">
|
340
|
-
<pre>
|
341
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/object.rb, line 16</span>
|
342
|
-
16: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">print_methods</span>
|
343
|
-
17: <span class="ruby-identifier">m</span> = <span class="ruby-node">"----- #{self} (methods) -----\n"</span>
|
344
|
-
18: <span class="ruby-identifier">m</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">methods</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n"</span>)
|
345
|
-
19: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">m</span>
|
346
|
-
20: <span class="ruby-identifier">m</span>
|
347
|
-
21: <span class="ruby-keyword kw">end</span>
|
348
|
-
</pre>
|
349
|
-
</div>
|
350
|
-
</div>
|
351
|
-
</div>
|
352
|
-
|
353
|
-
<div id="method-M000007" class="method-detail">
|
354
|
-
<a name="M000007"></a>
|
355
|
-
|
356
|
-
<div class="method-heading">
|
357
|
-
<a href="#M000007" class="method-signature">
|
358
|
-
<span class="method-name">running_time</span><span class="method-args">(message = "", logger = nil) {|if block_given?| ...}</span>
|
359
|
-
</a>
|
360
|
-
</div>
|
361
|
-
|
362
|
-
<div class="method-description">
|
363
|
-
<p>
|
364
|
-
This prints out running time for the block provided. This is great for
|
365
|
-
things like Rake tasks, etc… where you would like to know how long
|
366
|
-
it, or a section of it took to run.
|
367
|
-
</p>
|
368
|
-
<p><a class="source-toggle" href="#"
|
369
|
-
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
370
|
-
<div class="method-source-code" id="M000007-source">
|
371
|
-
<pre>
|
372
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/object.rb, line 65</span>
|
373
|
-
65: <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>)
|
374
|
-
66: <span class="ruby-identifier">s_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
375
|
-
67: <span class="ruby-identifier">s</span> = <span class="ruby-node">"---Starting at #{s_time}---"</span>
|
376
|
-
68: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">s</span>
|
377
|
-
69: <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>
|
378
|
-
70: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
379
|
-
71: <span class="ruby-identifier">e_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
380
|
-
72: <span class="ruby-identifier">e</span> = <span class="ruby-node">"---Ending at #{e_time}---"</span>
|
381
|
-
73: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">e</span>
|
382
|
-
74: <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>
|
383
|
-
75: <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>
|
384
|
-
76: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">secs</span> <span class="ruby-operator"><</span> <span class="ruby-value">60</span>
|
385
|
-
77: <span class="ruby-identifier">x</span> = <span class="ruby-node">"Running time #{secs} seconds."</span>
|
386
|
-
78: <span class="ruby-keyword kw">else</span>
|
387
|
-
79: <span class="ruby-identifier">x</span> = <span class="ruby-node">"Running time roughly #{secs/60} minutes [#{secs} seconds]"</span>
|
388
|
-
80: <span class="ruby-keyword kw">end</span>
|
389
|
-
81: <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>
|
390
|
-
82: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">x</span>
|
391
|
-
83: <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>
|
392
|
-
84: <span class="ruby-keyword kw">end</span>
|
393
|
-
</pre>
|
394
|
-
</div>
|
395
|
-
</div>
|
396
|
-
</div>
|
397
|
-
|
398
|
-
<div id="method-M000001" class="method-detail">
|
399
|
-
<a name="M000001"></a>
|
400
|
-
|
401
|
-
<div class="method-heading">
|
402
|
-
<a href="#M000001" class="method-signature">
|
403
|
-
<span class="method-name">safely_include_module</span><span class="method-args">(*modules)</span>
|
404
|
-
</a>
|
405
|
-
</div>
|
406
|
-
|
407
|
-
<div class="method-description">
|
408
|
-
<p>
|
409
|
-
Includes a module into the current <a href="Class.html">Class</a>, and
|
410
|
-
changes all the module‘s public methods to protected.
|
411
|
-
</p>
|
412
|
-
<p>
|
413
|
-
Example:
|
414
|
-
</p>
|
415
|
-
<pre>
|
416
|
-
class FooController
|
417
|
-
safely_include_module(MyCoolUtils, MyOtherModule)
|
418
|
-
end
|
419
|
-
</pre>
|
420
|
-
<p><a class="source-toggle" href="#"
|
421
|
-
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
422
|
-
<div class="method-source-code" id="M000001-source">
|
423
|
-
<pre>
|
424
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/object.rb, line 9</span>
|
425
|
-
9: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">safely_include_module</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">modules</span>)
|
426
|
-
10: [<span class="ruby-identifier">modules</span>].<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mod</span><span class="ruby-operator">|</span>
|
427
|
-
11: <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">include_safely_into</span>(<span class="ruby-keyword kw">self</span>)
|
428
|
-
12: <span class="ruby-keyword kw">end</span>
|
429
|
-
13: <span class="ruby-keyword kw">end</span>
|
430
|
-
</pre>
|
431
|
-
</div>
|
432
|
-
</div>
|
433
|
-
</div>
|
434
|
-
|
435
|
-
<div id="method-M000008" class="method-detail">
|
436
|
-
<a name="M000008"></a>
|
437
|
-
|
438
|
-
<div class="method-heading">
|
439
|
-
<a href="#M000008" class="method-signature">
|
440
|
-
<span class="method-name">send_with_chain</span><span class="method-args">(methods, *args)</span>
|
441
|
-
</a>
|
442
|
-
</div>
|
443
|
-
|
444
|
-
<div class="method-description">
|
445
|
-
<p>
|
446
|
-
This method will call send to all the methods defined on the previous
|
447
|
-
method.
|
448
|
-
</p>
|
449
|
-
<p>
|
450
|
-
Example:
|
451
|
-
</p>
|
452
|
-
<pre>
|
453
|
-
Fruit.send_with_chain([:new, :get_citrus, :get_orange, :class]) # => Orange
|
454
|
-
</pre>
|
455
|
-
<p>
|
456
|
-
This would be the equivalent:
|
457
|
-
</p>
|
458
|
-
<pre>
|
459
|
-
Fruit.new.get_citrus.get_orange.class
|
460
|
-
</pre>
|
461
|
-
<p><a class="source-toggle" href="#"
|
462
|
-
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
463
|
-
<div class="method-source-code" id="M000008-source">
|
464
|
-
<pre>
|
465
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/object.rb, line 93</span>
|
466
|
-
93: <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>)
|
467
|
-
94: <span class="ruby-identifier">obj</span> = <span class="ruby-keyword kw">self</span>
|
468
|
-
95: [<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>)}
|
469
|
-
96: <span class="ruby-identifier">obj</span>
|
470
|
-
97: <span class="ruby-keyword kw">end</span>
|
471
|
-
</pre>
|
472
|
-
</div>
|
473
|
-
</div>
|
474
|
-
</div>
|
475
|
-
|
476
|
-
<div id="method-M000005" class="method-detail">
|
477
|
-
<a name="M000005"></a>
|
478
|
-
|
479
|
-
<div class="method-heading">
|
480
|
-
<a href="#M000005" class="method-signature">
|
481
|
-
<span class="method-name">to_param</span><span class="method-args">()</span>
|
482
|
-
</a>
|
483
|
-
</div>
|
484
|
-
|
485
|
-
<div class="method-description">
|
486
|
-
<p>
|
487
|
-
This method gets called when a parameter is passed into a named route. This
|
488
|
-
can be overridden in an <a href="Object.html">Object</a> to provlde custom
|
489
|
-
handling of parameters.
|
490
|
-
</p>
|
491
|
-
<p><a class="source-toggle" href="#"
|
492
|
-
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
493
|
-
<div class="method-source-code" id="M000005-source">
|
494
|
-
<pre>
|
495
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/object.rb, line 49</span>
|
496
|
-
49: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_param</span>
|
497
|
-
50: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>
|
498
|
-
51: <span class="ruby-keyword kw">end</span>
|
499
|
-
</pre>
|
500
|
-
</div>
|
501
|
-
</div>
|
502
|
-
</div>
|
503
|
-
|
504
|
-
<div id="method-M000003" class="method-detail">
|
505
|
-
<a name="M000003"></a>
|
506
|
-
|
507
|
-
<div class="method-heading">
|
508
|
-
<a href="#M000003" class="method-signature">
|
509
|
-
<span class="method-name">with_options</span><span class="method-args">(options) {|Mack::Utils::OptionMerger.new(self, options)| ...}</span>
|
510
|
-
</a>
|
511
|
-
</div>
|
512
|
-
|
513
|
-
<div class="method-description">
|
514
|
-
<p>
|
515
|
-
An elegant way to refactor out common options
|
516
|
-
</p>
|
517
|
-
<pre>
|
518
|
-
with_options :order => 'created_at', :class_name => 'Comment' do |post|
|
519
|
-
post.has_many :comments, :conditions => ['approved = ?', true], :dependent => :delete_all
|
520
|
-
post.has_many :unapproved_comments, :conditions => ['approved = ?', false]
|
521
|
-
post.has_many :all_comments
|
522
|
-
end
|
523
|
-
</pre>
|
524
|
-
<p>
|
525
|
-
Can also be used with an explicit receiver:
|
526
|
-
</p>
|
527
|
-
<pre>
|
528
|
-
map.with_options :controller => "people" do |people|
|
529
|
-
people.connect "/people", :action => "index"
|
530
|
-
people.connect "/people/:id", :action => "show"
|
531
|
-
end
|
532
|
-
</pre>
|
533
|
-
<p><a class="source-toggle" href="#"
|
534
|
-
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
535
|
-
<div class="method-source-code" id="M000003-source">
|
536
|
-
<pre>
|
537
|
-
<span class="ruby-comment cmt"># File lib/mack-facets/extensions/object.rb, line 38</span>
|
538
|
-
38: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">with_options</span>(<span class="ruby-identifier">options</span>)
|
539
|
-
39: <span class="ruby-keyword kw">yield</span> <span class="ruby-constant">Mack</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">OptionMerger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">options</span>)
|
540
|
-
40: <span class="ruby-keyword kw">end</span>
|
541
|
-
</pre>
|
542
|
-
</div>
|
543
|
-
</div>
|
544
|
-
</div>
|
545
|
-
|
546
|
-
|
547
|
-
</div>
|
548
|
-
|
549
|
-
|
550
|
-
</div>
|
551
|
-
|
552
|
-
|
553
|
-
<div id="validator-badges">
|
554
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
555
|
-
</div>
|
556
|
-
|
557
|
-
</body>
|
558
|
-
</html>
|