rconfig 0.3.3 → 0.4.0
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/.gitignore +17 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/ChangeLog +50 -0
- data/Credits +13 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +30 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +0 -0
- data/Rakefile +11 -0
- data/demo/application.conf +3 -0
- data/demo/demo.conf +13 -0
- data/demo/demo.rb +14 -0
- data/demo/demo.xml +13 -0
- data/demo/demo.yml +12 -0
- data/doc/classes/ClassVariables.html +111 -0
- data/doc/classes/ConfigError.html +120 -0
- data/doc/classes/ConfigHash.html +354 -0
- data/doc/classes/Constants.html +226 -0
- data/doc/classes/Hash.html +269 -0
- data/doc/classes/InvalidConfigPathError.html +119 -0
- data/doc/classes/Object.html +220 -0
- data/doc/classes/PropertiesFileParser.html +282 -0
- data/doc/classes/RConfig.html +1745 -0
- data/doc/created.rid +1 -0
- data/doc/files/README_rdoc.html +271 -0
- data/doc/files/lib/rconfig/class_variables_rb.html +107 -0
- data/doc/files/lib/rconfig/config_hash_rb.html +114 -0
- data/doc/files/lib/rconfig/constants_rb.html +101 -0
- data/doc/files/lib/rconfig/core_ext/hash_rb.html +114 -0
- data/doc/files/lib/rconfig/core_ext/object_rb.html +101 -0
- data/doc/files/lib/rconfig/core_ext_rb.html +114 -0
- data/doc/files/lib/rconfig/exceptions_rb.html +110 -0
- data/doc/files/lib/rconfig/properties_file_parser_rb.html +146 -0
- data/doc/files/lib/rconfig/rconfig_rb.html +186 -0
- data/doc/files/lib/rconfig_rb.html +117 -0
- data/doc/fr_class_index.html +35 -0
- data/doc/fr_file_index.html +37 -0
- data/doc/fr_method_index.html +75 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/generators/rconfig/install_generator.rb +13 -0
- data/lib/generators/rconfig/templates/rconfig.rb +82 -0
- data/lib/rconfig.rb +98 -32
- data/lib/rconfig/callbacks.rb +46 -0
- data/lib/rconfig/cascade.rb +56 -0
- data/lib/rconfig/config.rb +78 -0
- data/lib/rconfig/constants.rb +58 -0
- data/lib/rconfig/core_ext/array.rb +3 -0
- data/lib/rconfig/core_ext/hash.rb +56 -57
- data/lib/rconfig/core_ext/nil.rb +5 -0
- data/lib/rconfig/core_ext/string.rb +3 -0
- data/lib/rconfig/core_methods.rb +276 -0
- data/lib/rconfig/exceptions.rb +21 -8
- data/lib/rconfig/load_paths.rb +55 -0
- data/lib/rconfig/logger.rb +86 -0
- data/lib/rconfig/properties_file.rb +138 -0
- data/lib/rconfig/reload.rb +75 -0
- data/lib/rconfig/settings.rb +93 -0
- data/lib/rconfig/utils.rb +175 -0
- data/lib/tasks/gem.rake +14 -0
- data/lib/tasks/rdoc.rake +11 -0
- data/lib/tasks/spec.rake +25 -0
- data/rconfig.gemspec +33 -0
- data/spec/core_ext/object_spec.rb +44 -0
- data/spec/rconfig_spec.rb +7 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +16 -0
- metadata +128 -32
- data/lib/rconfig/config_hash.rb +0 -105
- data/lib/rconfig/core_ext.rb +0 -6
- data/lib/rconfig/properties_file_parser.rb +0 -80
- data/lib/rconfig/rconfig.rb +0 -871
- data/test/rconfig_test.rb +0 -381
@@ -0,0 +1,269 @@
|
|
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/rconfig/core_ext/hash_rb.html">
|
59
|
+
lib/rconfig/core_ext/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
|
+
<div id="description">
|
84
|
+
<p>
|
85
|
+
source: <a
|
86
|
+
href="http://rubyforge.org/projects/facets">rubyforge.org/projects/facets</a>/
|
87
|
+
version: 1.7.46 license: Ruby License NOTE: remove this method if the
|
88
|
+
Facets gem is installed. BUG: <a href="Hash.html#M000010">weave</a> is
|
89
|
+
destructive to values in the source hash that are arrays!
|
90
|
+
</p>
|
91
|
+
<pre>
|
92
|
+
(this is acceptable for RConfig's use as the basis for weave!)
|
93
|
+
</pre>
|
94
|
+
|
95
|
+
</div>
|
96
|
+
|
97
|
+
|
98
|
+
</div>
|
99
|
+
|
100
|
+
<div id="method-list">
|
101
|
+
<h3 class="section-bar">Methods</h3>
|
102
|
+
|
103
|
+
<div class="name-list">
|
104
|
+
<a href="#M000010">weave</a>
|
105
|
+
<a href="#M000011">weave!</a>
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
|
109
|
+
</div>
|
110
|
+
|
111
|
+
|
112
|
+
<!-- if includes -->
|
113
|
+
|
114
|
+
<div id="section">
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
<!-- if method_list -->
|
124
|
+
<div id="methods">
|
125
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
126
|
+
|
127
|
+
<div id="method-M000010" class="method-detail">
|
128
|
+
<a name="M000010"></a>
|
129
|
+
|
130
|
+
<div class="method-heading">
|
131
|
+
<a href="#M000010" class="method-signature">
|
132
|
+
<span class="method-name">weave</span><span class="method-args">(other_hash, clobber = false)</span>
|
133
|
+
</a>
|
134
|
+
</div>
|
135
|
+
|
136
|
+
<div class="method-description">
|
137
|
+
<p>
|
138
|
+
Weaves the contents of two hashes producing a new hash.
|
139
|
+
</p>
|
140
|
+
<p><a class="source-toggle" href="#"
|
141
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
142
|
+
<div class="method-source-code" id="M000010-source">
|
143
|
+
<pre>
|
144
|
+
<span class="ruby-comment cmt"># File lib/rconfig/core_ext/hash.rb, line 14</span>
|
145
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">weave</span>(<span class="ruby-identifier">other_hash</span>, <span class="ruby-identifier">clobber</span> = <span class="ruby-keyword kw">false</span>)
|
146
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">other_hash</span>
|
147
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">other_hash</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Hash</span>)
|
148
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"RConfig: (Hash#weave) expected <Hash>, but was <#{other_hash.class}>"</span>
|
149
|
+
<span class="ruby-keyword kw">end</span>
|
150
|
+
|
151
|
+
<span class="ruby-identifier">self_dup</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dup</span> <span class="ruby-comment cmt"># self.clone does not remove freeze!</span>
|
152
|
+
|
153
|
+
<span class="ruby-identifier">other_hash</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">other_node</span><span class="ruby-operator">|</span>
|
154
|
+
|
155
|
+
<span class="ruby-identifier">self_dup</span>[<span class="ruby-identifier">key</span>] =
|
156
|
+
|
157
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">self_node</span> = <span class="ruby-identifier">self_dup</span>[<span class="ruby-identifier">key</span>]
|
158
|
+
|
159
|
+
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">self_node</span>
|
160
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-constant">Hash</span>
|
161
|
+
|
162
|
+
<span class="ruby-comment cmt"># hash1, hash2 => hash3 (recursive +)</span>
|
163
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">other_node</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
164
|
+
|
165
|
+
<span class="ruby-identifier">self_node</span>.<span class="ruby-identifier">weave</span>(<span class="ruby-identifier">other_node</span>, <span class="ruby-identifier">clobber</span>)
|
166
|
+
|
167
|
+
<span class="ruby-comment cmt"># hash, array => error (Can't weave'em, must clobber.)</span>
|
168
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">other_node</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>) <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">clobber</span>
|
169
|
+
|
170
|
+
<span class="ruby-identifier">raise</span>(<span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"RConfig: (Hash#weave) Can't weave Hash and Array"</span>)
|
171
|
+
|
172
|
+
<span class="ruby-comment cmt"># hash, array => hash[key] = array</span>
|
173
|
+
<span class="ruby-comment cmt"># hash, value => hash[key] = value</span>
|
174
|
+
<span class="ruby-keyword kw">else</span>
|
175
|
+
<span class="ruby-identifier">other_node</span>
|
176
|
+
<span class="ruby-keyword kw">end</span>
|
177
|
+
|
178
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-constant">Array</span>
|
179
|
+
|
180
|
+
<span class="ruby-comment cmt"># array, hash => array << hash</span>
|
181
|
+
<span class="ruby-comment cmt"># array1, array2 => array1 + array2</span>
|
182
|
+
<span class="ruby-comment cmt"># array, value => array << value</span>
|
183
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">clobber</span>
|
184
|
+
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">other_node</span>
|
185
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-constant">Hash</span>
|
186
|
+
<span class="ruby-identifier">self_node</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">other_node</span>
|
187
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-constant">Array</span>
|
188
|
+
<span class="ruby-identifier">self_node</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">other_node</span>
|
189
|
+
<span class="ruby-keyword kw">else</span>
|
190
|
+
<span class="ruby-identifier">self_node</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">other_node</span>
|
191
|
+
<span class="ruby-keyword kw">end</span>
|
192
|
+
|
193
|
+
<span class="ruby-comment cmt"># array, hash => hash</span>
|
194
|
+
<span class="ruby-comment cmt"># array1, array2 => array2</span>
|
195
|
+
<span class="ruby-comment cmt"># array, value => value</span>
|
196
|
+
<span class="ruby-keyword kw">else</span>
|
197
|
+
<span class="ruby-identifier">other_node</span>
|
198
|
+
<span class="ruby-keyword kw">end</span>
|
199
|
+
|
200
|
+
<span class="ruby-keyword kw">else</span>
|
201
|
+
|
202
|
+
<span class="ruby-comment cmt"># value, array => array.unshift(value)</span>
|
203
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">other_node</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>) <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">clobber</span>
|
204
|
+
<span class="ruby-identifier">other_node</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">self_node</span>)
|
205
|
+
|
206
|
+
<span class="ruby-comment cmt"># value1, value2 => value2</span>
|
207
|
+
<span class="ruby-keyword kw">else</span>
|
208
|
+
<span class="ruby-identifier">other_node</span>
|
209
|
+
<span class="ruby-keyword kw">end</span>
|
210
|
+
|
211
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-comment cmt"># case self_node</span>
|
212
|
+
|
213
|
+
<span class="ruby-comment cmt"># Target hash didn't have a node matching the key, </span>
|
214
|
+
<span class="ruby-comment cmt"># so just add it from the source hash.</span>
|
215
|
+
<span class="ruby-comment cmt"># !self_dup.has_key?(key) => self_dup.add(key, other_node)</span>
|
216
|
+
<span class="ruby-keyword kw">else</span>
|
217
|
+
<span class="ruby-identifier">other_node</span>
|
218
|
+
<span class="ruby-keyword kw">end</span>
|
219
|
+
|
220
|
+
} <span class="ruby-comment cmt"># other_hash.each</span>
|
221
|
+
|
222
|
+
<span class="ruby-identifier">self_dup</span> <span class="ruby-comment cmt"># return new weaved hash</span>
|
223
|
+
<span class="ruby-keyword kw">end</span>
|
224
|
+
</pre>
|
225
|
+
</div>
|
226
|
+
</div>
|
227
|
+
</div>
|
228
|
+
|
229
|
+
<div id="method-M000011" class="method-detail">
|
230
|
+
<a name="M000011"></a>
|
231
|
+
|
232
|
+
<div class="method-heading">
|
233
|
+
<a href="#M000011" class="method-signature">
|
234
|
+
<span class="method-name">weave!</span><span class="method-args">(other_hash, clobber = false)</span>
|
235
|
+
</a>
|
236
|
+
</div>
|
237
|
+
|
238
|
+
<div class="method-description">
|
239
|
+
<p>
|
240
|
+
Same as self.weave(other_hash, dont_clobber) except that it weaves other
|
241
|
+
hash to itself, rather than create a new hash.
|
242
|
+
</p>
|
243
|
+
<p><a class="source-toggle" href="#"
|
244
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
245
|
+
<div class="method-source-code" id="M000011-source">
|
246
|
+
<pre>
|
247
|
+
<span class="ruby-comment cmt"># File lib/rconfig/core_ext/hash.rb, line 97</span>
|
248
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">weave!</span>(<span class="ruby-identifier">other_hash</span>, <span class="ruby-identifier">clobber</span> = <span class="ruby-keyword kw">false</span>)
|
249
|
+
<span class="ruby-identifier">weaved_hash</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">weave</span>(<span class="ruby-identifier">other_hash</span>, <span class="ruby-identifier">clobber</span>)
|
250
|
+
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">weaved_hash</span>)
|
251
|
+
<span class="ruby-keyword kw">end</span>
|
252
|
+
</pre>
|
253
|
+
</div>
|
254
|
+
</div>
|
255
|
+
</div>
|
256
|
+
|
257
|
+
|
258
|
+
</div>
|
259
|
+
|
260
|
+
|
261
|
+
</div>
|
262
|
+
|
263
|
+
|
264
|
+
<div id="validator-badges">
|
265
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
266
|
+
</div>
|
267
|
+
|
268
|
+
</body>
|
269
|
+
</html>
|
@@ -0,0 +1,119 @@
|
|
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: InvalidConfigPathError</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">InvalidConfigPathError</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/lib/rconfig/exceptions_rb.html">
|
59
|
+
lib/rconfig/exceptions.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="ConfigError.html">
|
69
|
+
ConfigError
|
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
|
+
<div id="description">
|
84
|
+
<p>
|
85
|
+
Config path(s) are not set, don‘t exist, or Invalid in some manner
|
86
|
+
</p>
|
87
|
+
|
88
|
+
</div>
|
89
|
+
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
|
94
|
+
</div>
|
95
|
+
|
96
|
+
|
97
|
+
<!-- if includes -->
|
98
|
+
|
99
|
+
<div id="section">
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
<!-- if method_list -->
|
109
|
+
|
110
|
+
|
111
|
+
</div>
|
112
|
+
|
113
|
+
|
114
|
+
<div id="validator-badges">
|
115
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
116
|
+
</div>
|
117
|
+
|
118
|
+
</body>
|
119
|
+
</html>
|
@@ -0,0 +1,220 @@
|
|
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/rconfig/core_ext/object_rb.html">
|
59
|
+
lib/rconfig/core_ext/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="#M000002">config</a>
|
92
|
+
<a href="#M000001">try</a>
|
93
|
+
</div>
|
94
|
+
</div>
|
95
|
+
|
96
|
+
</div>
|
97
|
+
|
98
|
+
|
99
|
+
<!-- if includes -->
|
100
|
+
|
101
|
+
<div id="section">
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
<!-- if method_list -->
|
111
|
+
<div id="methods">
|
112
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
113
|
+
|
114
|
+
<div id="method-M000002" class="method-detail">
|
115
|
+
<a name="M000002"></a>
|
116
|
+
|
117
|
+
<div class="method-heading">
|
118
|
+
<a href="#M000002" class="method-signature">
|
119
|
+
<span class="method-name">config</span><span class="method-args">()</span>
|
120
|
+
</a>
|
121
|
+
</div>
|
122
|
+
|
123
|
+
<div class="method-description">
|
124
|
+
<p>
|
125
|
+
Convience method for short-hand access to class specific <a
|
126
|
+
href="Object.html#M000002">config</a>. If a <a
|
127
|
+
href="Object.html#M000002">config</a> specific to this class doesn‘t
|
128
|
+
exist, it‘ll return the root <a href="Object.html#M000002">config</a>
|
129
|
+
instance.
|
130
|
+
</p>
|
131
|
+
<p>
|
132
|
+
Example:
|
133
|
+
</p>
|
134
|
+
<pre>
|
135
|
+
# Given CONFIG_PATH/person.yml (with param sort_by_lastname: true)
|
136
|
+
@person = Person.new
|
137
|
+
@person.config => $config.person
|
138
|
+
@person.config.sort_by_lastname => true
|
139
|
+
|
140
|
+
# Given CONFIG_PATH/bank_account.yml (with param mask_account_number: true)
|
141
|
+
bank_acct = BankAccount.new
|
142
|
+
bank_acct.config => $config.bank_account
|
143
|
+
bank_acct.config.mask_account_number => true
|
144
|
+
|
145
|
+
# Given no specific config
|
146
|
+
@person = Person.new
|
147
|
+
@person.config => $config
|
148
|
+
@person.config.bank_account => $config.bank_account
|
149
|
+
</pre>
|
150
|
+
<p>
|
151
|
+
NOTE: If there is a class-specific <a href="Object.html#M000002">config</a>
|
152
|
+
file, and an object needs to
|
153
|
+
</p>
|
154
|
+
<pre>
|
155
|
+
access a different config, use the global instance ($config) or
|
156
|
+
the class (RConfig).
|
157
|
+
</pre>
|
158
|
+
<p><a class="source-toggle" href="#"
|
159
|
+
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
160
|
+
<div class="method-source-code" id="M000002-source">
|
161
|
+
<pre>
|
162
|
+
<span class="ruby-comment cmt"># File lib/rconfig/core_ext/object.rb, line 41</span>
|
163
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">config</span>
|
164
|
+
<span class="ruby-identifier">this_config</span> = <span class="ruby-identifier">$config</span>.<span class="ruby-identifier">send</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">underscore</span>.<span class="ruby-identifier">to_sym</span>)
|
165
|
+
<span class="ruby-identifier">this_config</span>.<span class="ruby-identifier">blank?</span> <span class="ruby-value">? </span><span class="ruby-identifier">$config</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">this_config</span>
|
166
|
+
<span class="ruby-keyword kw">end</span>
|
167
|
+
</pre>
|
168
|
+
</div>
|
169
|
+
</div>
|
170
|
+
</div>
|
171
|
+
|
172
|
+
<div id="method-M000001" class="method-detail">
|
173
|
+
<a name="M000001"></a>
|
174
|
+
|
175
|
+
<div class="method-heading">
|
176
|
+
<a href="#M000001" class="method-signature">
|
177
|
+
<span class="method-name">try</span><span class="method-args">(method, *args)</span>
|
178
|
+
</a>
|
179
|
+
</div>
|
180
|
+
|
181
|
+
<div class="method-description">
|
182
|
+
<pre>
|
183
|
+
@person ? @person.name : nil
|
184
|
+
- or -
|
185
|
+
</pre>
|
186
|
+
<p>
|
187
|
+
@people[:email] if @people
|
188
|
+
</p>
|
189
|
+
<pre>
|
190
|
+
- vs -
|
191
|
+
@person.try(:name)
|
192
|
+
</pre>
|
193
|
+
<p><a class="source-toggle" href="#"
|
194
|
+
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
195
|
+
<div class="method-source-code" id="M000001-source">
|
196
|
+
<pre>
|
197
|
+
<span class="ruby-comment cmt"># File lib/rconfig/core_ext/object.rb, line 9</span>
|
198
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">try</span>(<span class="ruby-identifier">method</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
199
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-identifier">send</span>(<span class="ruby-identifier">method</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">method</span>)
|
200
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-identifier">send</span>(<span class="ruby-identifier">:[]</span>, <span class="ruby-identifier">method</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:[]</span>)
|
201
|
+
<span class="ruby-identifier">result</span>
|
202
|
+
<span class="ruby-keyword kw">end</span>
|
203
|
+
</pre>
|
204
|
+
</div>
|
205
|
+
</div>
|
206
|
+
</div>
|
207
|
+
|
208
|
+
|
209
|
+
</div>
|
210
|
+
|
211
|
+
|
212
|
+
</div>
|
213
|
+
|
214
|
+
|
215
|
+
<div id="validator-badges">
|
216
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
217
|
+
</div>
|
218
|
+
|
219
|
+
</body>
|
220
|
+
</html>
|