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.
Files changed (74) hide show
  1. data/.gitignore +17 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc +1 -0
  4. data/ChangeLog +50 -0
  5. data/Credits +13 -0
  6. data/Gemfile +9 -0
  7. data/Gemfile.lock +30 -0
  8. data/LICENSE.txt +20 -0
  9. data/README.rdoc +0 -0
  10. data/Rakefile +11 -0
  11. data/demo/application.conf +3 -0
  12. data/demo/demo.conf +13 -0
  13. data/demo/demo.rb +14 -0
  14. data/demo/demo.xml +13 -0
  15. data/demo/demo.yml +12 -0
  16. data/doc/classes/ClassVariables.html +111 -0
  17. data/doc/classes/ConfigError.html +120 -0
  18. data/doc/classes/ConfigHash.html +354 -0
  19. data/doc/classes/Constants.html +226 -0
  20. data/doc/classes/Hash.html +269 -0
  21. data/doc/classes/InvalidConfigPathError.html +119 -0
  22. data/doc/classes/Object.html +220 -0
  23. data/doc/classes/PropertiesFileParser.html +282 -0
  24. data/doc/classes/RConfig.html +1745 -0
  25. data/doc/created.rid +1 -0
  26. data/doc/files/README_rdoc.html +271 -0
  27. data/doc/files/lib/rconfig/class_variables_rb.html +107 -0
  28. data/doc/files/lib/rconfig/config_hash_rb.html +114 -0
  29. data/doc/files/lib/rconfig/constants_rb.html +101 -0
  30. data/doc/files/lib/rconfig/core_ext/hash_rb.html +114 -0
  31. data/doc/files/lib/rconfig/core_ext/object_rb.html +101 -0
  32. data/doc/files/lib/rconfig/core_ext_rb.html +114 -0
  33. data/doc/files/lib/rconfig/exceptions_rb.html +110 -0
  34. data/doc/files/lib/rconfig/properties_file_parser_rb.html +146 -0
  35. data/doc/files/lib/rconfig/rconfig_rb.html +186 -0
  36. data/doc/files/lib/rconfig_rb.html +117 -0
  37. data/doc/fr_class_index.html +35 -0
  38. data/doc/fr_file_index.html +37 -0
  39. data/doc/fr_method_index.html +75 -0
  40. data/doc/index.html +24 -0
  41. data/doc/rdoc-style.css +208 -0
  42. data/lib/generators/rconfig/install_generator.rb +13 -0
  43. data/lib/generators/rconfig/templates/rconfig.rb +82 -0
  44. data/lib/rconfig.rb +98 -32
  45. data/lib/rconfig/callbacks.rb +46 -0
  46. data/lib/rconfig/cascade.rb +56 -0
  47. data/lib/rconfig/config.rb +78 -0
  48. data/lib/rconfig/constants.rb +58 -0
  49. data/lib/rconfig/core_ext/array.rb +3 -0
  50. data/lib/rconfig/core_ext/hash.rb +56 -57
  51. data/lib/rconfig/core_ext/nil.rb +5 -0
  52. data/lib/rconfig/core_ext/string.rb +3 -0
  53. data/lib/rconfig/core_methods.rb +276 -0
  54. data/lib/rconfig/exceptions.rb +21 -8
  55. data/lib/rconfig/load_paths.rb +55 -0
  56. data/lib/rconfig/logger.rb +86 -0
  57. data/lib/rconfig/properties_file.rb +138 -0
  58. data/lib/rconfig/reload.rb +75 -0
  59. data/lib/rconfig/settings.rb +93 -0
  60. data/lib/rconfig/utils.rb +175 -0
  61. data/lib/tasks/gem.rake +14 -0
  62. data/lib/tasks/rdoc.rake +11 -0
  63. data/lib/tasks/spec.rake +25 -0
  64. data/rconfig.gemspec +33 -0
  65. data/spec/core_ext/object_spec.rb +44 -0
  66. data/spec/rconfig_spec.rb +7 -0
  67. data/spec/spec.opts +4 -0
  68. data/spec/spec_helper.rb +16 -0
  69. metadata +128 -32
  70. data/lib/rconfig/config_hash.rb +0 -105
  71. data/lib/rconfig/core_ext.rb +0 -6
  72. data/lib/rconfig/properties_file_parser.rb +0 -80
  73. data/lib/rconfig/rconfig.rb +0 -871
  74. 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>&nbsp;&nbsp;
105
+ <a href="#M000011">weave!</a>&nbsp;&nbsp;
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">&quot;RConfig: (Hash#weave) expected &lt;Hash&gt;, but was &lt;#{other_hash.class}&gt;&quot;</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 =&gt; 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 =&gt; 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">&amp;&amp;</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">&quot;RConfig: (Hash#weave) Can't weave Hash and Array&quot;</span>)
171
+
172
+ <span class="ruby-comment cmt"># hash, array =&gt; hash[key] = array</span>
173
+ <span class="ruby-comment cmt"># hash, value =&gt; 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 =&gt; array &lt;&lt; hash</span>
181
+ <span class="ruby-comment cmt"># array1, array2 =&gt; array1 + array2</span>
182
+ <span class="ruby-comment cmt"># array, value =&gt; array &lt;&lt; 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">&lt;&lt;</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">&lt;&lt;</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 =&gt; hash</span>
194
+ <span class="ruby-comment cmt"># array1, array2 =&gt; array2</span>
195
+ <span class="ruby-comment cmt"># array, value =&gt; 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 =&gt; 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">&amp;&amp;</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 =&gt; 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) =&gt; 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&#8216;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>&nbsp;&nbsp;
92
+ <a href="#M000001">try</a>&nbsp;&nbsp;
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&#8216;t
128
+ exist, it&#8216;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 =&gt; $config.person
138
+ @person.config.sort_by_lastname =&gt; true
139
+
140
+ # Given CONFIG_PATH/bank_account.yml (with param mask_account_number: true)
141
+ bank_acct = BankAccount.new
142
+ bank_acct.config =&gt; $config.bank_account
143
+ bank_acct.config.mask_account_number =&gt; true
144
+
145
+ # Given no specific config
146
+ @person = Person.new
147
+ @person.config =&gt; $config
148
+ @person.config.bank_account =&gt; $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">&amp;&amp;</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>