configatron 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -92,14 +92,14 @@ The central class for managing the configurations.
92
92
  <h3 class="section-bar">Methods</h3>
93
93
 
94
94
  <div class="name-list">
95
- <a href="#M000011">configure</a>&nbsp;&nbsp;
96
- <a href="#M000012">configure_from_hash</a>&nbsp;&nbsp;
97
- <a href="#M000013">configure_from_yaml</a>&nbsp;&nbsp;
98
- <a href="#M000014">reload</a>&nbsp;&nbsp;
99
- <a href="#M000016">reset</a>&nbsp;&nbsp;
100
- <a href="#M000015">reset!</a>&nbsp;&nbsp;
101
- <a href="#M000017">revert</a>&nbsp;&nbsp;
102
- <a href="#M000018">to_hash</a>&nbsp;&nbsp;
95
+ <a href="#M000013">configure</a>&nbsp;&nbsp;
96
+ <a href="#M000014">configure_from_hash</a>&nbsp;&nbsp;
97
+ <a href="#M000015">configure_from_yaml</a>&nbsp;&nbsp;
98
+ <a href="#M000016">reload</a>&nbsp;&nbsp;
99
+ <a href="#M000018">reset</a>&nbsp;&nbsp;
100
+ <a href="#M000017">reset!</a>&nbsp;&nbsp;
101
+ <a href="#M000019">revert</a>&nbsp;&nbsp;
102
+ <a href="#M000020">to_hash</a>&nbsp;&nbsp;
103
103
  </div>
104
104
  </div>
105
105
 
@@ -147,11 +147,11 @@ NoMethodError exception will be raised.
147
147
  <div id="methods">
148
148
  <h3 class="section-bar">Public Instance methods</h3>
149
149
 
150
- <div id="method-M000011" class="method-detail">
151
- <a name="M000011"></a>
150
+ <div id="method-M000013" class="method-detail">
151
+ <a name="M000013"></a>
152
152
 
153
153
  <div class="method-heading">
154
- <a href="#M000011" class="method-signature">
154
+ <a href="#M000013" class="method-signature">
155
155
  <span class="method-name">configure</span><span class="method-args">() {|storage| ...}</span>
156
156
  </a>
157
157
  </div>
@@ -161,8 +161,8 @@ NoMethodError exception will be raised.
161
161
  Yields a new <a href="Store.html">Configatron::Store</a> class.
162
162
  </p>
163
163
  <p><a class="source-toggle" href="#"
164
- onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
165
- <div class="method-source-code" id="M000011-source">
164
+ onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
165
+ <div class="method-source-code" id="M000013-source">
166
166
  <pre>
167
167
  <span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 18</span>
168
168
  18: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure</span>
@@ -178,39 +178,40 @@ Yields a new <a href="Store.html">Configatron::Store</a> class.
178
178
  </div>
179
179
  </div>
180
180
 
181
- <div id="method-M000012" class="method-detail">
182
- <a name="M000012"></a>
181
+ <div id="method-M000014" class="method-detail">
182
+ <a name="M000014"></a>
183
183
 
184
184
  <div class="method-heading">
185
- <a href="#M000012" class="method-signature">
185
+ <a href="#M000014" class="method-signature">
186
186
  <span class="method-name">configure_from_hash</span><span class="method-args">(parameters)</span>
187
187
  </a>
188
188
  </div>
189
189
 
190
190
  <div class="method-description">
191
191
  <p>
192
- Used to load configuration settings from a Hash.
192
+ Used to load configuration settings from a <a href="../Hash.html">Hash</a>.
193
193
  </p>
194
194
  <p><a class="source-toggle" href="#"
195
- onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
196
- <div class="method-source-code" id="M000012-source">
195
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
196
+ <div class="method-source-code" id="M000014-source">
197
197
  <pre>
198
198
  <span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 28</span>
199
199
  28: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure_from_hash</span>(<span class="ruby-identifier">parameters</span>)
200
- 29: <span class="ruby-identifier">storage</span> = <span class="ruby-constant">Configatron</span><span class="ruby-operator">::</span><span class="ruby-constant">Store</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">parameters</span>)
201
- 30: <span class="ruby-ivar">@_storage_list</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">storage</span>
202
- 31: <span class="ruby-identifier">load_methods</span>(<span class="ruby-identifier">storage</span>)
203
- 32: <span class="ruby-keyword kw">end</span>
200
+ 29: <span class="ruby-identifier">parameters</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_hash</span>.<span class="ruby-identifier">recursive_merge</span>(<span class="ruby-identifier">parameters</span>)
201
+ 30: <span class="ruby-identifier">storage</span> = <span class="ruby-constant">Configatron</span><span class="ruby-operator">::</span><span class="ruby-constant">Store</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">parameters</span>)
202
+ 31: <span class="ruby-ivar">@_storage_list</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">storage</span>
203
+ 32: <span class="ruby-identifier">load_methods</span>(<span class="ruby-identifier">storage</span>)
204
+ 33: <span class="ruby-keyword kw">end</span>
204
205
  </pre>
205
206
  </div>
206
207
  </div>
207
208
  </div>
208
209
 
209
- <div id="method-M000013" class="method-detail">
210
- <a name="M000013"></a>
210
+ <div id="method-M000015" class="method-detail">
211
+ <a name="M000015"></a>
211
212
 
212
213
  <div class="method-heading">
213
- <a href="#M000013" class="method-signature">
214
+ <a href="#M000015" class="method-signature">
214
215
  <span class="method-name">configure_from_yaml</span><span class="method-args">(path)</span>
215
216
  </a>
216
217
  </div>
@@ -220,30 +221,30 @@ Used to load configuration settings from a Hash.
220
221
  Used to load configuration settings from a YAML file.
221
222
  </p>
222
223
  <p><a class="source-toggle" href="#"
223
- onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
224
- <div class="method-source-code" id="M000013-source">
224
+ onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
225
+ <div class="method-source-code" id="M000015-source">
225
226
  <pre>
226
- <span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 35</span>
227
- 35: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure_from_yaml</span>(<span class="ruby-identifier">path</span>)
228
- 36: <span class="ruby-keyword kw">begin</span>
229
- 37: <span class="ruby-identifier">storage</span> = <span class="ruby-constant">Configatron</span><span class="ruby-operator">::</span><span class="ruby-constant">YamlStore</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>)
230
- 38: <span class="ruby-ivar">@_storage_list</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">storage</span>
231
- 39: <span class="ruby-identifier">load_methods</span>(<span class="ruby-identifier">storage</span>)
232
- 40: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
233
- 41: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
234
- 42: <span class="ruby-comment cmt"># file doesn't exist.</span>
235
- 43: <span class="ruby-keyword kw">end</span>
236
- 44: <span class="ruby-keyword kw">end</span>
227
+ <span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 36</span>
228
+ 36: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure_from_yaml</span>(<span class="ruby-identifier">path</span>)
229
+ 37: <span class="ruby-keyword kw">begin</span>
230
+ 38: <span class="ruby-identifier">storage</span> = <span class="ruby-constant">Configatron</span><span class="ruby-operator">::</span><span class="ruby-constant">YamlStore</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>)
231
+ 39: <span class="ruby-ivar">@_storage_list</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">storage</span>
232
+ 40: <span class="ruby-identifier">load_methods</span>(<span class="ruby-identifier">storage</span>)
233
+ 41: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
234
+ 42: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
235
+ 43: <span class="ruby-comment cmt"># file doesn't exist.</span>
236
+ 44: <span class="ruby-keyword kw">end</span>
237
+ 45: <span class="ruby-keyword kw">end</span>
237
238
  </pre>
238
239
  </div>
239
240
  </div>
240
241
  </div>
241
242
 
242
- <div id="method-M000014" class="method-detail">
243
- <a name="M000014"></a>
243
+ <div id="method-M000016" class="method-detail">
244
+ <a name="M000016"></a>
244
245
 
245
246
  <div class="method-heading">
246
- <a href="#M000014" class="method-signature">
247
+ <a href="#M000016" class="method-signature">
247
248
  <span class="method-name">reload</span><span class="method-args">()</span>
248
249
  </a>
249
250
  </div>
@@ -253,26 +254,26 @@ Used to load configuration settings from a YAML file.
253
254
  Replays the history of configurations.
254
255
  </p>
255
256
  <p><a class="source-toggle" href="#"
256
- onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
257
- <div class="method-source-code" id="M000014-source">
257
+ onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
258
+ <div class="method-source-code" id="M000016-source">
258
259
  <pre>
259
- <span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 47</span>
260
- 47: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reload</span>
261
- 48: <span class="ruby-ivar">@_storage_list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">storage</span><span class="ruby-operator">|</span>
262
- 49: <span class="ruby-identifier">storage</span>.<span class="ruby-identifier">reload</span>
263
- 50: <span class="ruby-identifier">load_methods</span>(<span class="ruby-identifier">storage</span>)
264
- 51: <span class="ruby-keyword kw">end</span>
265
- 52: <span class="ruby-keyword kw">end</span>
260
+ <span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 48</span>
261
+ 48: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reload</span>
262
+ 49: <span class="ruby-ivar">@_storage_list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">storage</span><span class="ruby-operator">|</span>
263
+ 50: <span class="ruby-identifier">storage</span>.<span class="ruby-identifier">reload</span>
264
+ 51: <span class="ruby-identifier">load_methods</span>(<span class="ruby-identifier">storage</span>)
265
+ 52: <span class="ruby-keyword kw">end</span>
266
+ 53: <span class="ruby-keyword kw">end</span>
266
267
  </pre>
267
268
  </div>
268
269
  </div>
269
270
  </div>
270
271
 
271
- <div id="method-M000016" class="method-detail">
272
- <a name="M000016"></a>
272
+ <div id="method-M000018" class="method-detail">
273
+ <a name="M000018"></a>
273
274
 
274
275
  <div class="method-heading">
275
- <a href="#M000016" class="method-signature">
276
+ <a href="#M000018" class="method-signature">
276
277
  <span class="method-name">reset</span><span class="method-args">()</span>
277
278
  </a>
278
279
  </div>
@@ -282,64 +283,64 @@ Replays the history of configurations.
282
283
  All methods are undefined.
283
284
  </p>
284
285
  <p><a class="source-toggle" href="#"
285
- onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
286
- <div class="method-source-code" id="M000016-source">
286
+ onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
287
+ <div class="method-source-code" id="M000018-source">
287
288
  <pre>
288
- <span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 64</span>
289
- 64: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset</span>
290
- 65: <span class="ruby-ivar">@_storage_list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">storage</span><span class="ruby-operator">|</span>
291
- 66: <span class="ruby-identifier">storage</span>.<span class="ruby-identifier">parameters</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
292
- 67: <span class="ruby-constant">Configatron</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">instance_eval</span> <span class="ruby-keyword kw">do</span>
293
- 68: <span class="ruby-keyword kw">begin</span>
294
- 69: <span class="ruby-identifier">undef_method</span>(<span class="ruby-identifier">k</span>)
295
- 70: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">NameError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
296
- 71: <span class="ruby-keyword kw">end</span>
297
- 72: <span class="ruby-keyword kw">end</span>
298
- 73: <span class="ruby-keyword kw">end</span>
299
- 74: <span class="ruby-keyword kw">end</span>
300
- 75: <span class="ruby-keyword kw">end</span>
289
+ <span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 65</span>
290
+ 65: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset</span>
291
+ 66: <span class="ruby-ivar">@_storage_list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">storage</span><span class="ruby-operator">|</span>
292
+ 67: <span class="ruby-identifier">storage</span>.<span class="ruby-identifier">parameters</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
293
+ 68: <span class="ruby-constant">Configatron</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">instance_eval</span> <span class="ruby-keyword kw">do</span>
294
+ 69: <span class="ruby-keyword kw">begin</span>
295
+ 70: <span class="ruby-identifier">undef_method</span>(<span class="ruby-identifier">k</span>)
296
+ 71: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">NameError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
297
+ 72: <span class="ruby-keyword kw">end</span>
298
+ 73: <span class="ruby-keyword kw">end</span>
299
+ 74: <span class="ruby-keyword kw">end</span>
300
+ 75: <span class="ruby-keyword kw">end</span>
301
+ 76: <span class="ruby-keyword kw">end</span>
301
302
  </pre>
302
303
  </div>
303
304
  </div>
304
305
  </div>
305
306
 
306
- <div id="method-M000015" class="method-detail">
307
- <a name="M000015"></a>
307
+ <div id="method-M000017" class="method-detail">
308
+ <a name="M000017"></a>
308
309
 
309
310
  <div class="method-heading">
310
- <a href="#M000015" class="method-signature">
311
+ <a href="#M000017" class="method-signature">
311
312
  <span class="method-name">reset!</span><span class="method-args">()</span>
312
313
  </a>
313
314
  </div>
314
315
 
315
316
  <div class="method-description">
316
317
  <p>
317
- Does a hard <a href="Configuration.html#M000016">reset</a> of the <a
318
+ Does a hard <a href="Configuration.html#M000018">reset</a> of the <a
318
319
  href="Configuration.html">Configatron::Configuration</a> class. All methods
319
320
  are undefined, the list of configuration parameters is emptied, and the
320
- nil_for_missing method gets <a href="Configuration.html#M000016">reset</a>
321
+ nil_for_missing method gets <a href="Configuration.html#M000018">reset</a>
321
322
  to false.
322
323
  </p>
323
324
  <p><a class="source-toggle" href="#"
324
- onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
325
- <div class="method-source-code" id="M000015-source">
325
+ onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
326
+ <div class="method-source-code" id="M000017-source">
326
327
  <pre>
327
- <span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 57</span>
328
- 57: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset!</span>
329
- 58: <span class="ruby-identifier">reset</span>
330
- 59: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">nil_for_missing</span> = <span class="ruby-keyword kw">false</span>
331
- 60: <span class="ruby-ivar">@_storage_list</span> = []
332
- 61: <span class="ruby-keyword kw">end</span>
328
+ <span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 58</span>
329
+ 58: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset!</span>
330
+ 59: <span class="ruby-identifier">reset</span>
331
+ 60: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">nil_for_missing</span> = <span class="ruby-keyword kw">false</span>
332
+ 61: <span class="ruby-ivar">@_storage_list</span> = []
333
+ 62: <span class="ruby-keyword kw">end</span>
333
334
  </pre>
334
335
  </div>
335
336
  </div>
336
337
  </div>
337
338
 
338
- <div id="method-M000017" class="method-detail">
339
- <a name="M000017"></a>
339
+ <div id="method-M000019" class="method-detail">
340
+ <a name="M000019"></a>
340
341
 
341
342
  <div class="method-heading">
342
- <a href="#M000017" class="method-signature">
343
+ <a href="#M000019" class="method-signature">
343
344
  <span class="method-name">revert</span><span class="method-args">(step = 1)</span>
344
345
  </a>
345
346
  </div>
@@ -349,38 +350,38 @@ to false.
349
350
  Peels back n number of configuration parameters.
350
351
  </p>
351
352
  <p><a class="source-toggle" href="#"
352
- onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
353
- <div class="method-source-code" id="M000017-source">
353
+ onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
354
+ <div class="method-source-code" id="M000019-source">
354
355
  <pre>
355
- <span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 78</span>
356
- 78: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">revert</span>(<span class="ruby-identifier">step</span> = <span class="ruby-value">1</span>)
357
- 79: <span class="ruby-identifier">reset</span>
358
- 80: <span class="ruby-identifier">step</span>.<span class="ruby-identifier">times</span> {<span class="ruby-ivar">@_storage_list</span>.<span class="ruby-identifier">pop</span>}
359
- 81: <span class="ruby-identifier">reload</span>
360
- 82: <span class="ruby-keyword kw">end</span>
356
+ <span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 79</span>
357
+ 79: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">revert</span>(<span class="ruby-identifier">step</span> = <span class="ruby-value">1</span>)
358
+ 80: <span class="ruby-identifier">reset</span>
359
+ 81: <span class="ruby-identifier">step</span>.<span class="ruby-identifier">times</span> {<span class="ruby-ivar">@_storage_list</span>.<span class="ruby-identifier">pop</span>}
360
+ 82: <span class="ruby-identifier">reload</span>
361
+ 83: <span class="ruby-keyword kw">end</span>
361
362
  </pre>
362
363
  </div>
363
364
  </div>
364
365
  </div>
365
366
 
366
- <div id="method-M000018" class="method-detail">
367
- <a name="M000018"></a>
367
+ <div id="method-M000020" class="method-detail">
368
+ <a name="M000020"></a>
368
369
 
369
370
  <div class="method-heading">
370
- <a href="#M000018" class="method-signature">
371
+ <a href="#M000020" class="method-signature">
371
372
  <span class="method-name">to_hash</span><span class="method-args">()</span>
372
373
  </a>
373
374
  </div>
374
375
 
375
376
  <div class="method-description">
376
377
  <p><a class="source-toggle" href="#"
377
- onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
378
- <div class="method-source-code" id="M000018-source">
378
+ onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
379
+ <div class="method-source-code" id="M000020-source">
379
380
  <pre>
380
- <span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 88</span>
381
- 88: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>
382
- 89: <span class="ruby-ivar">@_storage_list</span>.<span class="ruby-identifier">inject</span>({}) { <span class="ruby-operator">|</span><span class="ruby-identifier">acc</span>, <span class="ruby-identifier">storage</span><span class="ruby-operator">|</span> <span class="ruby-identifier">acc</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">storage</span>.<span class="ruby-identifier">to_hash</span>) }
383
- 90: <span class="ruby-keyword kw">end</span>
381
+ <span class="ruby-comment cmt"># File lib/configatron/configuration.rb, line 89</span>
382
+ 89: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>
383
+ 90: <span class="ruby-ivar">@_storage_list</span>.<span class="ruby-identifier">inject</span>({}) { <span class="ruby-operator">|</span><span class="ruby-identifier">acc</span>, <span class="ruby-identifier">storage</span><span class="ruby-operator">|</span> <span class="ruby-identifier">acc</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">storage</span>.<span class="ruby-identifier">to_hash</span>) }
384
+ 91: <span class="ruby-keyword kw">end</span>
384
385
  </pre>
385
386
  </div>
386
387
  </div>
@@ -80,8 +80,8 @@
80
80
  <h3 class="section-bar">Methods</h3>
81
81
 
82
82
  <div class="name-list">
83
- <a href="#M000001">exists?</a>&nbsp;&nbsp;
84
- <a href="#M000002">retrieve</a>&nbsp;&nbsp;
83
+ <a href="#M000003">exists?</a>&nbsp;&nbsp;
84
+ <a href="#M000004">retrieve</a>&nbsp;&nbsp;
85
85
  </div>
86
86
  </div>
87
87
 
@@ -103,11 +103,11 @@
103
103
  <div id="methods">
104
104
  <h3 class="section-bar">Public Instance methods</h3>
105
105
 
106
- <div id="method-M000001" class="method-detail">
107
- <a name="M000001"></a>
106
+ <div id="method-M000003" class="method-detail">
107
+ <a name="M000003"></a>
108
108
 
109
109
  <div class="method-heading">
110
- <a href="#M000001" class="method-signature">
110
+ <a href="#M000003" class="method-signature">
111
111
  <span class="method-name">exists?</span><span class="method-args">(name)</span>
112
112
  </a>
113
113
  </div>
@@ -117,8 +117,8 @@
117
117
  Checks whether or not configuration parameter exists.
118
118
  </p>
119
119
  <p><a class="source-toggle" href="#"
120
- onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
121
- <div class="method-source-code" id="M000001-source">
120
+ onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
121
+ <div class="method-source-code" id="M000003-source">
122
122
  <pre>
123
123
  <span class="ruby-comment cmt"># File lib/configatron/helpers.rb, line 5</span>
124
124
  5: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">name</span>)
@@ -129,11 +129,11 @@ Checks whether or not configuration parameter exists.
129
129
  </div>
130
130
  </div>
131
131
 
132
- <div id="method-M000002" class="method-detail">
133
- <a name="M000002"></a>
132
+ <div id="method-M000004" class="method-detail">
133
+ <a name="M000004"></a>
134
134
 
135
135
  <div class="method-heading">
136
- <a href="#M000002" class="method-signature">
136
+ <a href="#M000004" class="method-signature">
137
137
  <span class="method-name">retrieve</span><span class="method-args">(name, default_value = ArgumentError)</span>
138
138
  </a>
139
139
  </div>
@@ -145,8 +145,8 @@ be passed that will be returned if the config parameter doesn&#8216;t
145
145
  exist.
146
146
  </p>
147
147
  <p><a class="source-toggle" href="#"
148
- onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
149
- <div class="method-source-code" id="M000002-source">
148
+ onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
149
+ <div class="method-source-code" id="M000004-source">
150
150
  <pre>
151
151
  <span class="ruby-comment cmt"># File lib/configatron/helpers.rb, line 20</span>
152
152
  20: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrieve</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">default_value</span> = <span class="ruby-constant">ArgumentError</span>)
@@ -92,12 +92,12 @@ Used to store each of the &#8216;sets&#8217; of configuration parameters.
92
92
  <h3 class="section-bar">Methods</h3>
93
93
 
94
94
  <div class="name-list">
95
- <a href="#M000005">exists?</a>&nbsp;&nbsp;
96
- <a href="#M000004">method_missing</a>&nbsp;&nbsp;
97
- <a href="#M000006">namespace</a>&nbsp;&nbsp;
98
- <a href="#M000003">new</a>&nbsp;&nbsp;
99
- <a href="#M000007">reload</a>&nbsp;&nbsp;
100
- <a href="#M000008">to_hash</a>&nbsp;&nbsp;
95
+ <a href="#M000007">exists?</a>&nbsp;&nbsp;
96
+ <a href="#M000006">method_missing</a>&nbsp;&nbsp;
97
+ <a href="#M000008">namespace</a>&nbsp;&nbsp;
98
+ <a href="#M000005">new</a>&nbsp;&nbsp;
99
+ <a href="#M000009">reload</a>&nbsp;&nbsp;
100
+ <a href="#M000010">to_hash</a>&nbsp;&nbsp;
101
101
  </div>
102
102
  </div>
103
103
 
@@ -142,22 +142,22 @@ The actual key/pair parameter values.
142
142
  <div id="methods">
143
143
  <h3 class="section-bar">Public Class methods</h3>
144
144
 
145
- <div id="method-M000003" class="method-detail">
146
- <a name="M000003"></a>
145
+ <div id="method-M000005" class="method-detail">
146
+ <a name="M000005"></a>
147
147
 
148
148
  <div class="method-heading">
149
- <a href="#M000003" class="method-signature">
149
+ <a href="#M000005" class="method-signature">
150
150
  <span class="method-name">new</span><span class="method-args">(parameters = {})</span>
151
151
  </a>
152
152
  </div>
153
153
 
154
154
  <div class="method-description">
155
155
  <p>
156
- Takes an optional Hash to configure parameters.
156
+ Takes an optional <a href="../Hash.html">Hash</a> to configure parameters.
157
157
  </p>
158
158
  <p><a class="source-toggle" href="#"
159
- onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
160
- <div class="method-source-code" id="M000003-source">
159
+ onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
160
+ <div class="method-source-code" id="M000005-source">
161
161
  <pre>
162
162
  <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 10</span>
163
163
  10: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">parameters</span> = {})
@@ -174,11 +174,11 @@ Takes an optional Hash to configure parameters.
174
174
 
175
175
  <h3 class="section-bar">Public Instance methods</h3>
176
176
 
177
- <div id="method-M000005" class="method-detail">
178
- <a name="M000005"></a>
177
+ <div id="method-M000007" class="method-detail">
178
+ <a name="M000007"></a>
179
179
 
180
180
  <div class="method-heading">
181
- <a href="#M000005" class="method-signature">
181
+ <a href="#M000007" class="method-signature">
182
182
  <span class="method-name">exists?</span><span class="method-args">(name)</span>
183
183
  </a>
184
184
  </div>
@@ -188,8 +188,8 @@ Takes an optional Hash to configure parameters.
188
188
  Checks whether or not configuration parameter exists.
189
189
  </p>
190
190
  <p><a class="source-toggle" href="#"
191
- onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
192
- <div class="method-source-code" id="M000005-source">
191
+ onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
192
+ <div class="method-source-code" id="M000007-source">
193
193
  <pre>
194
194
  <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 37</span>
195
195
  37: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">name</span>)
@@ -201,11 +201,11 @@ Checks whether or not configuration parameter exists.
201
201
  </div>
202
202
  </div>
203
203
 
204
- <div id="method-M000004" class="method-detail">
205
- <a name="M000004"></a>
204
+ <div id="method-M000006" class="method-detail">
205
+ <a name="M000006"></a>
206
206
 
207
207
  <div class="method-heading">
208
- <a href="#M000004" class="method-signature">
208
+ <a href="#M000006" class="method-signature">
209
209
  <span class="method-name">method_missing</span><span class="method-args">(sym, *args)</span>
210
210
  </a>
211
211
  </div>
@@ -219,8 +219,8 @@ names. If a method is called without an = sign at the end then the value
219
219
  from the parameters hash is returned, if it exists.
220
220
  </p>
221
221
  <p><a class="source-toggle" href="#"
222
- onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
223
- <div class="method-source-code" id="M000004-source">
222
+ onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
223
+ <div class="method-source-code" id="M000006-source">
224
224
  <pre>
225
225
  <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 23</span>
226
226
  23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
@@ -240,11 +240,11 @@ from the parameters hash is returned, if it exists.
240
240
  </div>
241
241
  </div>
242
242
 
243
- <div id="method-M000006" class="method-detail">
244
- <a name="M000006"></a>
243
+ <div id="method-M000008" class="method-detail">
244
+ <a name="M000008"></a>
245
245
 
246
246
  <div class="method-heading">
247
- <a href="#M000006" class="method-signature">
247
+ <a href="#M000008" class="method-signature">
248
248
  <span class="method-name">namespace</span><span class="method-args">(name) {|self.send(name.to_sym)| ...}</span>
249
249
  </a>
250
250
  </div>
@@ -255,8 +255,8 @@ Used to create &#8216;namespaces&#8217; around a set of configuration
255
255
  parameters.
256
256
  </p>
257
257
  <p><a class="source-toggle" href="#"
258
- onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
259
- <div class="method-source-code" id="M000006-source">
258
+ onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
259
+ <div class="method-source-code" id="M000008-source">
260
260
  <pre>
261
261
  <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 43</span>
262
262
  43: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">namespace</span>(<span class="ruby-identifier">name</span>)
@@ -275,24 +275,24 @@ parameters.
275
275
  </div>
276
276
  </div>
277
277
 
278
- <div id="method-M000007" class="method-detail">
279
- <a name="M000007"></a>
278
+ <div id="method-M000009" class="method-detail">
279
+ <a name="M000009"></a>
280
280
 
281
281
  <div class="method-heading">
282
- <a href="#M000007" class="method-signature">
282
+ <a href="#M000009" class="method-signature">
283
283
  <span class="method-name">reload</span><span class="method-args">()</span>
284
284
  </a>
285
285
  </div>
286
286
 
287
287
  <div class="method-description">
288
288
  <p>
289
- Called when a <a href="Store.html#M000007">reload</a> is called on
289
+ Called when a <a href="Store.html#M000009">reload</a> is called on
290
290
  configatron. Useful for subclasses that may need to read a file in,
291
291
  etc&#8230;
292
292
  </p>
293
293
  <p><a class="source-toggle" href="#"
294
- onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
295
- <div class="method-source-code" id="M000007-source">
294
+ onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
295
+ <div class="method-source-code" id="M000009-source">
296
296
  <pre>
297
297
  <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 57</span>
298
298
  57: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reload</span>
@@ -302,19 +302,19 @@ etc&#8230;
302
302
  </div>
303
303
  </div>
304
304
 
305
- <div id="method-M000008" class="method-detail">
306
- <a name="M000008"></a>
305
+ <div id="method-M000010" class="method-detail">
306
+ <a name="M000010"></a>
307
307
 
308
308
  <div class="method-heading">
309
- <a href="#M000008" class="method-signature">
309
+ <a href="#M000010" class="method-signature">
310
310
  <span class="method-name">to_hash</span><span class="method-args">()</span>
311
311
  </a>
312
312
  </div>
313
313
 
314
314
  <div class="method-description">
315
315
  <p><a class="source-toggle" href="#"
316
- onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
317
- <div class="method-source-code" id="M000008-source">
316
+ onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
317
+ <div class="method-source-code" id="M000010-source">
318
318
  <pre>
319
319
  <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 60</span>
320
320
  60: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>
@@ -95,8 +95,8 @@ that came from a YAML file.
95
95
  <h3 class="section-bar">Methods</h3>
96
96
 
97
97
  <div class="name-list">
98
- <a href="#M000009">new</a>&nbsp;&nbsp;
99
- <a href="#M000010">reload</a>&nbsp;&nbsp;
98
+ <a href="#M000011">new</a>&nbsp;&nbsp;
99
+ <a href="#M000012">reload</a>&nbsp;&nbsp;
100
100
  </div>
101
101
  </div>
102
102
 
@@ -131,11 +131,11 @@ that came from a YAML file.
131
131
  <div id="methods">
132
132
  <h3 class="section-bar">Public Class methods</h3>
133
133
 
134
- <div id="method-M000009" class="method-detail">
135
- <a name="M000009"></a>
134
+ <div id="method-M000011" class="method-detail">
135
+ <a name="M000011"></a>
136
136
 
137
137
  <div class="method-heading">
138
- <a href="#M000009" class="method-signature">
138
+ <a href="#M000011" class="method-signature">
139
139
  <span class="method-name">new</span><span class="method-args">(file_location)</span>
140
140
  </a>
141
141
  </div>
@@ -145,8 +145,8 @@ that came from a YAML file.
145
145
  Takes the full path to the YAML file.
146
146
  </p>
147
147
  <p><a class="source-toggle" href="#"
148
- onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
149
- <div class="method-source-code" id="M000009-source">
148
+ onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
149
+ <div class="method-source-code" id="M000011-source">
150
150
  <pre>
151
151
  <span class="ruby-comment cmt"># File lib/configatron/yaml_store.rb, line 9</span>
152
152
  9: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">file_location</span>)
@@ -160,11 +160,11 @@ Takes the full path to the YAML file.
160
160
 
161
161
  <h3 class="section-bar">Public Instance methods</h3>
162
162
 
163
- <div id="method-M000010" class="method-detail">
164
- <a name="M000010"></a>
163
+ <div id="method-M000012" class="method-detail">
164
+ <a name="M000012"></a>
165
165
 
166
166
  <div class="method-heading">
167
- <a href="#M000010" class="method-signature">
167
+ <a href="#M000012" class="method-signature">
168
168
  <span class="method-name">reload</span><span class="method-args">()</span>
169
169
  </a>
170
170
  </div>
@@ -174,8 +174,8 @@ Takes the full path to the YAML file.
174
174
  Re-reads the YAML file.
175
175
  </p>
176
176
  <p><a class="source-toggle" href="#"
177
- onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
178
- <div class="method-source-code" id="M000010-source">
177
+ onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
178
+ <div class="method-source-code" id="M000012-source">
179
179
  <pre>
180
180
  <span class="ruby-comment cmt"># File lib/configatron/yaml_store.rb, line 15</span>
181
181
  15: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reload</span>
@@ -0,0 +1,193 @@
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/configatron_rb.html">
59
+ lib/configatron.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
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000001">recursive_merge</a>&nbsp;&nbsp;
90
+ <a href="#M000002">recursive_merge!</a>&nbsp;&nbsp;
91
+ </div>
92
+ </div>
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
+ <div id="methods">
110
+ <h3 class="section-bar">Public Instance methods</h3>
111
+
112
+ <div id="method-M000001" class="method-detail">
113
+ <a name="M000001"></a>
114
+
115
+ <div class="method-heading">
116
+ <a href="#M000001" class="method-signature">
117
+ <span class="method-name">recursive_merge</span><span class="method-args">(other)</span>
118
+ </a>
119
+ </div>
120
+
121
+ <div class="method-description">
122
+ <p>
123
+ Same as Hash#merge but recursively merges sub-hashes.
124
+ </p>
125
+ <p><a class="source-toggle" href="#"
126
+ onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
127
+ <div class="method-source-code" id="M000001-source">
128
+ <pre>
129
+ <span class="ruby-comment cmt"># File lib/configatron.rb, line 17</span>
130
+ 17: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">recursive_merge</span>(<span class="ruby-identifier">other</span>)
131
+ 18: <span class="ruby-identifier">hash</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dup</span>
132
+ 19: <span class="ruby-identifier">other</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
133
+ 20: <span class="ruby-identifier">myval</span> = <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">key</span>]
134
+ 21: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">myval</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
135
+ 22: <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">myval</span>.<span class="ruby-identifier">recursive_merge</span>(<span class="ruby-identifier">value</span>)
136
+ 23: <span class="ruby-keyword kw">else</span>
137
+ 24: <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
138
+ 25: <span class="ruby-keyword kw">end</span>
139
+ 26: <span class="ruby-keyword kw">end</span>
140
+ 27: <span class="ruby-identifier">hash</span>
141
+ 28: <span class="ruby-keyword kw">end</span>
142
+ </pre>
143
+ </div>
144
+ </div>
145
+ </div>
146
+
147
+ <div id="method-M000002" class="method-detail">
148
+ <a name="M000002"></a>
149
+
150
+ <div class="method-heading">
151
+ <a href="#M000002" class="method-signature">
152
+ <span class="method-name">recursive_merge!</span><span class="method-args">(other)</span>
153
+ </a>
154
+ </div>
155
+
156
+ <div class="method-description">
157
+ <p>
158
+ Same as Hash#merge! but recursively merges sub-hashes.
159
+ </p>
160
+ <p><a class="source-toggle" href="#"
161
+ onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
162
+ <div class="method-source-code" id="M000002-source">
163
+ <pre>
164
+ <span class="ruby-comment cmt"># File lib/configatron.rb, line 32</span>
165
+ 32: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">recursive_merge!</span>(<span class="ruby-identifier">other</span>)
166
+ 33: <span class="ruby-identifier">other</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
167
+ 34: <span class="ruby-identifier">myval</span> = <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">key</span>]
168
+ 35: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">myval</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
169
+ 36: <span class="ruby-identifier">myval</span>.<span class="ruby-identifier">recursive_merge!</span>(<span class="ruby-identifier">value</span>)
170
+ 37: <span class="ruby-keyword kw">else</span>
171
+ 38: <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
172
+ 39: <span class="ruby-keyword kw">end</span>
173
+ 40: <span class="ruby-keyword kw">end</span>
174
+ 41: <span class="ruby-keyword kw">self</span>
175
+ 42: <span class="ruby-keyword kw">end</span>
176
+ </pre>
177
+ </div>
178
+ </div>
179
+ </div>
180
+
181
+
182
+ </div>
183
+
184
+
185
+ </div>
186
+
187
+
188
+ <div id="validator-badges">
189
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
190
+ </div>
191
+
192
+ </body>
193
+ </html>
@@ -80,7 +80,7 @@
80
80
  <h3 class="section-bar">Methods</h3>
81
81
 
82
82
  <div class="name-list">
83
- <a href="#M000019">configatron</a>&nbsp;&nbsp;
83
+ <a href="#M000021">configatron</a>&nbsp;&nbsp;
84
84
  </div>
85
85
  </div>
86
86
 
@@ -102,11 +102,11 @@
102
102
  <div id="methods">
103
103
  <h3 class="section-bar">Public Instance methods</h3>
104
104
 
105
- <div id="method-M000019" class="method-detail">
106
- <a name="M000019"></a>
105
+ <div id="method-M000021" class="method-detail">
106
+ <a name="M000021"></a>
107
107
 
108
108
  <div class="method-heading">
109
- <a href="#M000019" class="method-signature">
109
+ <a href="#M000021" class="method-signature">
110
110
  <span class="method-name">configatron</span><span class="method-args">(&amp;block)</span>
111
111
  </a>
112
112
  </div>
@@ -120,8 +120,8 @@ Configatron::Configatron configure method and yield up a <a
120
120
  href="Configatron/Store.html">Configatron::Store</a> object.
121
121
  </p>
122
122
  <p><a class="source-toggle" href="#"
123
- onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
124
- <div class="method-source-code" id="M000019-source">
123
+ onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
124
+ <div class="method-source-code" id="M000021-source">
125
125
  <pre>
126
126
  <span class="ruby-comment cmt"># File lib/configatron/kernel.rb, line 6</span>
127
127
  6: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configatron</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
data/doc/created.rid CHANGED
@@ -1 +1 @@
1
- Wed, 10 Sep 2008 16:12:28 -0400
1
+ Mon, 15 Sep 2008 11:06:30 -0400
@@ -120,7 +120,7 @@ becomes:
120
120
  Notice how our other configuration parameters haven&#8216;t changed? Cool,
121
121
  eh?
122
122
  </p>
123
- <h3>Hash/YAML</h3>
123
+ <h3><a href="../classes/Hash.html">Hash</a>/YAML</h3>
124
124
  <p>
125
125
  You can configure configatron from a hash as well:
126
126
  </p>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Wed Sep 10 16:09:29 -0400 2008</td>
59
+ <td>Mon Sep 15 11:06:00 -0400 2008</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Wed Sep 10 16:09:29 -0400 2008</td>
59
+ <td>Mon Sep 15 10:59:23 -0400 2008</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Fri Sep 05 16:22:37 -0400 2008</td>
59
+ <td>Mon Sep 15 11:05:40 -0400 2008</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -24,6 +24,7 @@
24
24
  <a href="classes/Configatron/Helpers.html">Configatron::Helpers</a><br />
25
25
  <a href="classes/Configatron/Store.html">Configatron::Store</a><br />
26
26
  <a href="classes/Configatron/YamlStore.html">Configatron::YamlStore</a><br />
27
+ <a href="classes/Hash.html">Hash</a><br />
27
28
  <a href="classes/Kernel.html">Kernel</a><br />
28
29
  </div>
29
30
  </div>
@@ -20,25 +20,27 @@
20
20
  <div id="index">
21
21
  <h1 class="section-bar">Methods</h1>
22
22
  <div id="index-entries">
23
- <a href="classes/Kernel.html#M000019">configatron (Kernel)</a><br />
24
- <a href="classes/Configatron/Configuration.html#M000011">configure (Configatron::Configuration)</a><br />
25
- <a href="classes/Configatron/Configuration.html#M000012">configure_from_hash (Configatron::Configuration)</a><br />
26
- <a href="classes/Configatron/Configuration.html#M000013">configure_from_yaml (Configatron::Configuration)</a><br />
27
- <a href="classes/Configatron/Store.html#M000005">exists? (Configatron::Store)</a><br />
28
- <a href="classes/Configatron/Helpers.html#M000001">exists? (Configatron::Helpers)</a><br />
29
- <a href="classes/Configatron/Store.html#M000004">method_missing (Configatron::Store)</a><br />
30
- <a href="classes/Configatron/Store.html#M000006">namespace (Configatron::Store)</a><br />
31
- <a href="classes/Configatron/YamlStore.html#M000009">new (Configatron::YamlStore)</a><br />
32
- <a href="classes/Configatron/Store.html#M000003">new (Configatron::Store)</a><br />
33
- <a href="classes/Configatron/Configuration.html#M000014">reload (Configatron::Configuration)</a><br />
34
- <a href="classes/Configatron/Store.html#M000007">reload (Configatron::Store)</a><br />
35
- <a href="classes/Configatron/YamlStore.html#M000010">reload (Configatron::YamlStore)</a><br />
36
- <a href="classes/Configatron/Configuration.html#M000016">reset (Configatron::Configuration)</a><br />
37
- <a href="classes/Configatron/Configuration.html#M000015">reset! (Configatron::Configuration)</a><br />
38
- <a href="classes/Configatron/Helpers.html#M000002">retrieve (Configatron::Helpers)</a><br />
39
- <a href="classes/Configatron/Configuration.html#M000017">revert (Configatron::Configuration)</a><br />
40
- <a href="classes/Configatron/Configuration.html#M000018">to_hash (Configatron::Configuration)</a><br />
41
- <a href="classes/Configatron/Store.html#M000008">to_hash (Configatron::Store)</a><br />
23
+ <a href="classes/Kernel.html#M000021">configatron (Kernel)</a><br />
24
+ <a href="classes/Configatron/Configuration.html#M000013">configure (Configatron::Configuration)</a><br />
25
+ <a href="classes/Configatron/Configuration.html#M000014">configure_from_hash (Configatron::Configuration)</a><br />
26
+ <a href="classes/Configatron/Configuration.html#M000015">configure_from_yaml (Configatron::Configuration)</a><br />
27
+ <a href="classes/Configatron/Helpers.html#M000003">exists? (Configatron::Helpers)</a><br />
28
+ <a href="classes/Configatron/Store.html#M000007">exists? (Configatron::Store)</a><br />
29
+ <a href="classes/Configatron/Store.html#M000006">method_missing (Configatron::Store)</a><br />
30
+ <a href="classes/Configatron/Store.html#M000008">namespace (Configatron::Store)</a><br />
31
+ <a href="classes/Configatron/Store.html#M000005">new (Configatron::Store)</a><br />
32
+ <a href="classes/Configatron/YamlStore.html#M000011">new (Configatron::YamlStore)</a><br />
33
+ <a href="classes/Hash.html#M000001">recursive_merge (Hash)</a><br />
34
+ <a href="classes/Hash.html#M000002">recursive_merge! (Hash)</a><br />
35
+ <a href="classes/Configatron/YamlStore.html#M000012">reload (Configatron::YamlStore)</a><br />
36
+ <a href="classes/Configatron/Store.html#M000009">reload (Configatron::Store)</a><br />
37
+ <a href="classes/Configatron/Configuration.html#M000016">reload (Configatron::Configuration)</a><br />
38
+ <a href="classes/Configatron/Configuration.html#M000018">reset (Configatron::Configuration)</a><br />
39
+ <a href="classes/Configatron/Configuration.html#M000017">reset! (Configatron::Configuration)</a><br />
40
+ <a href="classes/Configatron/Helpers.html#M000004">retrieve (Configatron::Helpers)</a><br />
41
+ <a href="classes/Configatron/Configuration.html#M000019">revert (Configatron::Configuration)</a><br />
42
+ <a href="classes/Configatron/Configuration.html#M000020">to_hash (Configatron::Configuration)</a><br />
43
+ <a href="classes/Configatron/Store.html#M000010">to_hash (Configatron::Store)</a><br />
42
44
  </div>
43
45
  </div>
44
46
  </body>
@@ -26,6 +26,7 @@ module Configatron
26
26
 
27
27
  # Used to load configuration settings from a Hash.
28
28
  def configure_from_hash(parameters)
29
+ parameters = self.to_hash.recursive_merge(parameters)
29
30
  storage = Configatron::Store.new(parameters)
30
31
  @_storage_list << storage
31
32
  load_methods(storage)
data/lib/configatron.rb CHANGED
@@ -8,4 +8,38 @@ require File.join(File.dirname(__FILE__), 'configatron', 'store')
8
8
  require File.join(File.dirname(__FILE__), 'configatron', 'yaml_store')
9
9
 
10
10
  module Configatron # :nodoc:
11
- end
11
+ end
12
+
13
+ class Hash
14
+
15
+ # Same as Hash#merge but recursively merges sub-hashes.
16
+
17
+ def recursive_merge(other)
18
+ hash = self.dup
19
+ other.each do |key, value|
20
+ myval = self[key]
21
+ if value.is_a?(Hash) && myval.is_a?(Hash)
22
+ hash[key] = myval.recursive_merge(value)
23
+ else
24
+ hash[key] = value
25
+ end
26
+ end
27
+ hash
28
+ end
29
+
30
+ # Same as Hash#merge! but recursively merges sub-hashes.
31
+
32
+ def recursive_merge!(other)
33
+ other.each do |key, value|
34
+ myval = self[key]
35
+ if value.is_a?(Hash) && myval.is_a?(Hash)
36
+ myval.recursive_merge!(value)
37
+ else
38
+ self[key] = value
39
+ end
40
+ end
41
+ self
42
+ end
43
+
44
+ end
45
+
@@ -28,6 +28,23 @@ describe Configatron::Configuration do
28
28
  configatron.homer.should == "Homer Simpson"
29
29
  end
30
30
 
31
+ it "doesn't wipe out existing configurations" do
32
+ configatron do |c|
33
+ c.namespace(:mack) do |mack|
34
+ mack.one = 1
35
+ mack.two = 2
36
+ mack.three = 3
37
+ end
38
+ c.a = 'a'
39
+ c.b = 'b'
40
+ end
41
+ configatron.to_hash.should == {:mack => {:one => 1, :two => 2, :three => 3}, :a => 'a', :b => 'b'}
42
+ configatron.configure_from_hash(:mack => {:one => 'one'}, :b => 'bee')
43
+ configatron.to_hash.should == {:mack => {:one => 'one', :two => 2, :three => 3}, :a => 'a', :b => 'bee'}
44
+ configatron.revert
45
+ configatron.to_hash.should == {:mack => {:one => 1, :two => 2, :three => 3}, :a => 'a', :b => 'b'}
46
+ end
47
+
31
48
  end
32
49
 
33
50
  describe "hashes to namespace" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configatron
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - markbates
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-10 00:00:00 -04:00
12
+ date: 2008-09-15 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -33,6 +33,7 @@ files:
33
33
  - doc/classes/Configatron/Helpers.html
34
34
  - doc/classes/Configatron/Store.html
35
35
  - doc/classes/Configatron/YamlStore.html
36
+ - doc/classes/Hash.html
36
37
  - doc/classes/Kernel.html
37
38
  - doc/created.rid
38
39
  - doc/files/lib/configatron/configuration_rb.html