configatron 2.0.0 → 2.1.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/doc/classes/Configatron/ProtectedParameter.html +6 -6
- data/doc/classes/Configatron/Store.html +134 -42
- data/doc/classes/Kernel.html +6 -6
- data/doc/created.rid +1 -1
- data/doc/files/README.html +1 -1
- data/doc/files/lib/configatron/configatron_rb.html +1 -1
- data/doc/files/lib/configatron/errors_rb.html +1 -1
- data/doc/files/lib/configatron/kernel_rb.html +1 -1
- data/doc/files/lib/configatron/store_rb.html +1 -1
- data/doc/files/lib/configatron_rb.html +1 -1
- data/doc/fr_method_index.html +6 -3
- data/lib/configatron/store.rb +25 -0
- data/spec/lib/configatron_spec.rb +30 -0
- metadata +2 -2
@@ -86,7 +86,7 @@
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
87
87
|
|
88
88
|
<div class="name-list">
|
89
|
-
<a href="#
|
89
|
+
<a href="#M000017">intialize</a>
|
90
90
|
</div>
|
91
91
|
</div>
|
92
92
|
|
@@ -108,19 +108,19 @@
|
|
108
108
|
<div id="methods">
|
109
109
|
<h3 class="section-bar">Public Instance methods</h3>
|
110
110
|
|
111
|
-
<div id="method-
|
112
|
-
<a name="
|
111
|
+
<div id="method-M000017" class="method-detail">
|
112
|
+
<a name="M000017"></a>
|
113
113
|
|
114
114
|
<div class="method-heading">
|
115
|
-
<a href="#
|
115
|
+
<a href="#M000017" class="method-signature">
|
116
116
|
<span class="method-name">intialize</span><span class="method-args">(name)</span>
|
117
117
|
</a>
|
118
118
|
</div>
|
119
119
|
|
120
120
|
<div class="method-description">
|
121
121
|
<p><a class="source-toggle" href="#"
|
122
|
-
onclick="toggleCode('
|
123
|
-
<div class="method-source-code" id="
|
122
|
+
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
123
|
+
<div class="method-source-code" id="M000017-source">
|
124
124
|
<pre>
|
125
125
|
<span class="ruby-comment cmt"># File lib/configatron/errors.rb, line 3</span>
|
126
126
|
3: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">intialize</span>(<span class="ruby-identifier">name</span>)
|
@@ -88,14 +88,17 @@
|
|
88
88
|
<div class="name-list">
|
89
89
|
<a href="#M000006">configure_from_hash</a>
|
90
90
|
<a href="#M000007">configure_from_yaml</a>
|
91
|
-
<a href="#
|
91
|
+
<a href="#M000016">deep_clone</a>
|
92
92
|
<a href="#M000004">new</a>
|
93
93
|
<a href="#M000008">nil?</a>
|
94
94
|
<a href="#M000012">protect</a>
|
95
|
+
<a href="#M000013">protect_all!</a>
|
95
96
|
<a href="#M000010">remove</a>
|
96
97
|
<a href="#M000009">retrieve</a>
|
97
98
|
<a href="#M000011">set_default</a>
|
98
99
|
<a href="#M000005">to_hash</a>
|
100
|
+
<a href="#M000014">unprotect</a>
|
101
|
+
<a href="#M000015">unprotect_all!</a>
|
99
102
|
</div>
|
100
103
|
</div>
|
101
104
|
|
@@ -204,11 +207,11 @@ to the YAML file.
|
|
204
207
|
</div>
|
205
208
|
</div>
|
206
209
|
|
207
|
-
<div id="method-
|
208
|
-
<a name="
|
210
|
+
<div id="method-M000016" class="method-detail">
|
211
|
+
<a name="M000016"></a>
|
209
212
|
|
210
213
|
<div class="method-heading">
|
211
|
-
<a href="#
|
214
|
+
<a href="#M000016" class="method-signature">
|
212
215
|
<span class="method-name">deep_clone</span><span class="method-args">( obj=self, cloned={} )</span>
|
213
216
|
</a>
|
214
217
|
</div>
|
@@ -256,41 +259,41 @@ href="http://simplypowerful.1984.cz/goodlibs/1.2006.05.23">simplypowerful.1984.c
|
|
256
259
|
either the dual license version in 2003, or any later version.
|
257
260
|
</pre>
|
258
261
|
<p><a class="source-toggle" href="#"
|
259
|
-
onclick="toggleCode('
|
260
|
-
<div class="method-source-code" id="
|
262
|
+
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
263
|
+
<div class="method-source-code" id="M000016-source">
|
261
264
|
<pre>
|
262
|
-
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
265
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 143</span>
|
266
|
+
143: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">deep_clone</span>( <span class="ruby-identifier">obj</span>=<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">cloned</span>={} )
|
267
|
+
144: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cloned</span>.<span class="ruby-identifier">has_key?</span>( <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">object_id</span> )
|
268
|
+
145: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">cloned</span>[<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">object_id</span>]
|
269
|
+
146: <span class="ruby-keyword kw">else</span>
|
270
|
+
147: <span class="ruby-keyword kw">begin</span>
|
271
|
+
148: <span class="ruby-identifier">cl</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">clone</span>
|
272
|
+
149: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
|
273
|
+
150: <span class="ruby-comment cmt"># unclonnable (TrueClass, Fixnum, ...)</span>
|
274
|
+
151: <span class="ruby-identifier">cloned</span>[<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">object_id</span>] = <span class="ruby-identifier">obj</span>
|
275
|
+
152: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">obj</span>
|
276
|
+
153: <span class="ruby-keyword kw">else</span>
|
277
|
+
154: <span class="ruby-identifier">cloned</span>[<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">object_id</span>] = <span class="ruby-identifier">cl</span>
|
278
|
+
155: <span class="ruby-identifier">cloned</span>[<span class="ruby-identifier">cl</span>.<span class="ruby-identifier">object_id</span>] = <span class="ruby-identifier">cl</span>
|
279
|
+
156: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cl</span>.<span class="ruby-identifier">is_a?</span>( <span class="ruby-constant">Hash</span> )
|
280
|
+
157: <span class="ruby-identifier">cl</span>.<span class="ruby-identifier">clone</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
281
|
+
158: <span class="ruby-identifier">cl</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">deep_clone</span>( <span class="ruby-identifier">v</span>, <span class="ruby-identifier">cloned</span> )
|
282
|
+
159: }
|
283
|
+
160: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">cl</span>.<span class="ruby-identifier">is_a?</span>( <span class="ruby-constant">Array</span> )
|
284
|
+
161: <span class="ruby-identifier">cl</span>.<span class="ruby-identifier">collect!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
285
|
+
162: <span class="ruby-identifier">deep_clone</span>( <span class="ruby-identifier">v</span>, <span class="ruby-identifier">cloned</span> )
|
286
|
+
163: }
|
287
|
+
164: <span class="ruby-keyword kw">end</span>
|
288
|
+
165: <span class="ruby-identifier">cl</span>.<span class="ruby-identifier">instance_variables</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">var</span><span class="ruby-operator">|</span>
|
289
|
+
166: <span class="ruby-identifier">v</span> = <span class="ruby-identifier">cl</span>.<span class="ruby-identifier">instance_eval</span>( <span class="ruby-identifier">var</span> )
|
290
|
+
167: <span class="ruby-identifier">v_cl</span> = <span class="ruby-identifier">deep_clone</span>( <span class="ruby-identifier">v</span>, <span class="ruby-identifier">cloned</span> )
|
291
|
+
168: <span class="ruby-identifier">cl</span>.<span class="ruby-identifier">instance_eval</span>( <span class="ruby-node">"#{var} = v_cl"</span> )
|
292
|
+
169: <span class="ruby-keyword kw">end</span>
|
293
|
+
170: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">cl</span>
|
294
|
+
171: <span class="ruby-keyword kw">end</span>
|
295
|
+
172: <span class="ruby-keyword kw">end</span>
|
296
|
+
173: <span class="ruby-keyword kw">end</span>
|
294
297
|
</pre>
|
295
298
|
</div>
|
296
299
|
</div>
|
@@ -332,14 +335,50 @@ Returns true if there are no configuration parameters
|
|
332
335
|
</div>
|
333
336
|
|
334
337
|
<div class="method-description">
|
338
|
+
<p>
|
339
|
+
Prevents a parameter from being reassigned. If called on a
|
340
|
+
‘namespace’ then all parameters below it will be protected as
|
341
|
+
well.
|
342
|
+
</p>
|
335
343
|
<p><a class="source-toggle" href="#"
|
336
344
|
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
337
345
|
<div class="method-source-code" id="M000012-source">
|
338
346
|
<pre>
|
339
|
-
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line
|
340
|
-
|
341
|
-
|
342
|
-
|
347
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 80</span>
|
348
|
+
80: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">protect</span>(<span class="ruby-identifier">name</span>)
|
349
|
+
81: <span class="ruby-ivar">@_protected</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>
|
350
|
+
82: <span class="ruby-keyword kw">end</span>
|
351
|
+
</pre>
|
352
|
+
</div>
|
353
|
+
</div>
|
354
|
+
</div>
|
355
|
+
|
356
|
+
<div id="method-M000013" class="method-detail">
|
357
|
+
<a name="M000013"></a>
|
358
|
+
|
359
|
+
<div class="method-heading">
|
360
|
+
<a href="#M000013" class="method-signature">
|
361
|
+
<span class="method-name">protect_all!</span><span class="method-args">()</span>
|
362
|
+
</a>
|
363
|
+
</div>
|
364
|
+
|
365
|
+
<div class="method-description">
|
366
|
+
<p>
|
367
|
+
Prevents all parameters from being reassigned.
|
368
|
+
</p>
|
369
|
+
<p><a class="source-toggle" href="#"
|
370
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
371
|
+
<div class="method-source-code" id="M000013-source">
|
372
|
+
<pre>
|
373
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 85</span>
|
374
|
+
85: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">protect_all!</span>
|
375
|
+
86: <span class="ruby-ivar">@_protected</span>.<span class="ruby-identifier">clear</span>
|
376
|
+
87: <span class="ruby-ivar">@_store</span>.<span class="ruby-identifier">keys</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-operator">|</span>
|
377
|
+
88: <span class="ruby-identifier">val</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">k</span>)
|
378
|
+
89: <span class="ruby-identifier">val</span>.<span class="ruby-identifier">protect_all!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Configatron</span><span class="ruby-operator">::</span><span class="ruby-constant">Store</span>
|
379
|
+
90: <span class="ruby-ivar">@_protected</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">k</span>
|
380
|
+
91: <span class="ruby-keyword kw">end</span>
|
381
|
+
92: <span class="ruby-keyword kw">end</span>
|
343
382
|
</pre>
|
344
383
|
</div>
|
345
384
|
</div>
|
@@ -454,6 +493,59 @@ Returns a Hash representing the configurations
|
|
454
493
|
</div>
|
455
494
|
</div>
|
456
495
|
|
496
|
+
<div id="method-M000014" class="method-detail">
|
497
|
+
<a name="M000014"></a>
|
498
|
+
|
499
|
+
<div class="method-heading">
|
500
|
+
<a href="#M000014" class="method-signature">
|
501
|
+
<span class="method-name">unprotect</span><span class="method-args">(name)</span>
|
502
|
+
</a>
|
503
|
+
</div>
|
504
|
+
|
505
|
+
<div class="method-description">
|
506
|
+
<p>
|
507
|
+
Removes the protection of a parameter.
|
508
|
+
</p>
|
509
|
+
<p><a class="source-toggle" href="#"
|
510
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
511
|
+
<div class="method-source-code" id="M000014-source">
|
512
|
+
<pre>
|
513
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 95</span>
|
514
|
+
95: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unprotect</span>(<span class="ruby-identifier">name</span>)
|
515
|
+
96: <span class="ruby-ivar">@_protected</span>.<span class="ruby-identifier">reject!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span> }
|
516
|
+
97: <span class="ruby-keyword kw">end</span>
|
517
|
+
</pre>
|
518
|
+
</div>
|
519
|
+
</div>
|
520
|
+
</div>
|
521
|
+
|
522
|
+
<div id="method-M000015" class="method-detail">
|
523
|
+
<a name="M000015"></a>
|
524
|
+
|
525
|
+
<div class="method-heading">
|
526
|
+
<a href="#M000015" class="method-signature">
|
527
|
+
<span class="method-name">unprotect_all!</span><span class="method-args">()</span>
|
528
|
+
</a>
|
529
|
+
</div>
|
530
|
+
|
531
|
+
<div class="method-description">
|
532
|
+
<p><a class="source-toggle" href="#"
|
533
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
534
|
+
<div class="method-source-code" id="M000015-source">
|
535
|
+
<pre>
|
536
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 99</span>
|
537
|
+
99: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unprotect_all!</span>
|
538
|
+
100: <span class="ruby-ivar">@_protected</span>.<span class="ruby-identifier">clear</span>
|
539
|
+
101: <span class="ruby-ivar">@_store</span>.<span class="ruby-identifier">keys</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-operator">|</span>
|
540
|
+
102: <span class="ruby-identifier">val</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">k</span>)
|
541
|
+
103: <span class="ruby-identifier">val</span>.<span class="ruby-identifier">unprotect_all!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Configatron</span><span class="ruby-operator">::</span><span class="ruby-constant">Store</span>
|
542
|
+
104: <span class="ruby-keyword kw">end</span>
|
543
|
+
105: <span class="ruby-keyword kw">end</span>
|
544
|
+
</pre>
|
545
|
+
</div>
|
546
|
+
</div>
|
547
|
+
</div>
|
548
|
+
|
457
549
|
|
458
550
|
</div>
|
459
551
|
|
data/doc/classes/Kernel.html
CHANGED
@@ -80,7 +80,7 @@
|
|
80
80
|
<h3 class="section-bar">Methods</h3>
|
81
81
|
|
82
82
|
<div class="name-list">
|
83
|
-
<a href="#
|
83
|
+
<a href="#M000018">configatron</a>
|
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-
|
106
|
-
<a name="
|
105
|
+
<div id="method-M000018" class="method-detail">
|
106
|
+
<a name="M000018"></a>
|
107
107
|
|
108
108
|
<div class="method-heading">
|
109
|
-
<a href="#
|
109
|
+
<a href="#M000018" class="method-signature">
|
110
110
|
<span class="method-name">configatron</span><span class="method-args">()</span>
|
111
111
|
</a>
|
112
112
|
</div>
|
@@ -117,8 +117,8 @@ Provides access to the <a href="Configatron.html">Configatron</a> storage
|
|
117
117
|
system.
|
118
118
|
</p>
|
119
119
|
<p><a class="source-toggle" href="#"
|
120
|
-
onclick="toggleCode('
|
121
|
-
<div class="method-source-code" id="
|
120
|
+
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
121
|
+
<div class="method-source-code" id="M000018-source">
|
122
122
|
<pre>
|
123
123
|
<span class="ruby-comment cmt"># File lib/configatron/kernel.rb, line 4</span>
|
124
124
|
4: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configatron</span>
|
data/doc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Thu, 18 Sep 2008 12:40:45 -0400
|
data/doc/files/README.html
CHANGED
data/doc/fr_method_index.html
CHANGED
@@ -20,21 +20,24 @@
|
|
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#
|
23
|
+
<a href="classes/Kernel.html#M000018">configatron (Kernel)</a><br />
|
24
24
|
<a href="classes/Configatron/Store.html#M000006">configure_from_hash (Configatron::Store)</a><br />
|
25
25
|
<a href="classes/Configatron/Store.html#M000007">configure_from_yaml (Configatron::Store)</a><br />
|
26
|
-
<a href="classes/Configatron/Store.html#
|
27
|
-
<a href="classes/Configatron/ProtectedParameter.html#
|
26
|
+
<a href="classes/Configatron/Store.html#M000016">deep_clone (Configatron::Store)</a><br />
|
27
|
+
<a href="classes/Configatron/ProtectedParameter.html#M000017">intialize (Configatron::ProtectedParameter)</a><br />
|
28
28
|
<a href="classes/Configatron.html#M000001">method_missing (Configatron)</a><br />
|
29
29
|
<a href="classes/Configatron/Store.html#M000004">new (Configatron::Store)</a><br />
|
30
30
|
<a href="classes/Configatron/Store.html#M000008">nil? (Configatron::Store)</a><br />
|
31
31
|
<a href="classes/Configatron/Store.html#M000012">protect (Configatron::Store)</a><br />
|
32
|
+
<a href="classes/Configatron/Store.html#M000013">protect_all! (Configatron::Store)</a><br />
|
32
33
|
<a href="classes/Configatron/Store.html#M000010">remove (Configatron::Store)</a><br />
|
33
34
|
<a href="classes/Configatron.html#M000002">reset! (Configatron)</a><br />
|
34
35
|
<a href="classes/Configatron/Store.html#M000009">retrieve (Configatron::Store)</a><br />
|
35
36
|
<a href="classes/Configatron/Store.html#M000011">set_default (Configatron::Store)</a><br />
|
36
37
|
<a href="classes/Configatron.html#M000003">temp (Configatron)</a><br />
|
37
38
|
<a href="classes/Configatron/Store.html#M000005">to_hash (Configatron::Store)</a><br />
|
39
|
+
<a href="classes/Configatron/Store.html#M000014">unprotect (Configatron::Store)</a><br />
|
40
|
+
<a href="classes/Configatron/Store.html#M000015">unprotect_all! (Configatron::Store)</a><br />
|
38
41
|
</div>
|
39
42
|
</div>
|
40
43
|
</body>
|
data/lib/configatron/store.rb
CHANGED
@@ -75,10 +75,35 @@ class Configatron
|
|
75
75
|
self.to_hash == other
|
76
76
|
end
|
77
77
|
|
78
|
+
# Prevents a parameter from being reassigned. If called on a 'namespace' then
|
79
|
+
# all parameters below it will be protected as well.
|
78
80
|
def protect(name)
|
79
81
|
@_protected << name.to_sym
|
80
82
|
end
|
81
83
|
|
84
|
+
# Prevents all parameters from being reassigned.
|
85
|
+
def protect_all!
|
86
|
+
@_protected.clear
|
87
|
+
@_store.keys.each do |k|
|
88
|
+
val = self.send(k)
|
89
|
+
val.protect_all! if val.class == Configatron::Store
|
90
|
+
@_protected << k
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Removes the protection of a parameter.
|
95
|
+
def unprotect(name)
|
96
|
+
@_protected.reject! { |e| e == name.to_sym }
|
97
|
+
end
|
98
|
+
|
99
|
+
def unprotect_all!
|
100
|
+
@_protected.clear
|
101
|
+
@_store.keys.each do |k|
|
102
|
+
val = self.send(k)
|
103
|
+
val.unprotect_all! if val.class == Configatron::Store
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
82
107
|
# = DeepClone
|
83
108
|
#
|
84
109
|
# == Version
|
@@ -39,6 +39,36 @@ describe "configatron" do
|
|
39
39
|
lambda{configatron.configure_from_hash(:letters => 'letters')}.should raise_error(Configatron::ProtectedParameter)
|
40
40
|
end
|
41
41
|
|
42
|
+
it "should be able to protect all parameters at once" do
|
43
|
+
configatron.one = 1
|
44
|
+
configatron.letters.a = 'A'
|
45
|
+
configatron.letters.b = 'B'
|
46
|
+
configatron.protect_all!
|
47
|
+
[:a,:b].each do |l|
|
48
|
+
lambda{configatron.configure_from_hash(:letters => {l => l.to_s})}.should raise_error(Configatron::ProtectedParameter)
|
49
|
+
configatron.letters.send(l).should == l.to_s.upcase
|
50
|
+
end
|
51
|
+
lambda{configatron.letters.configure_from_hash(:a => 'a')}.should raise_error(Configatron::ProtectedParameter)
|
52
|
+
lambda{configatron.configure_from_hash(:letters => 'letters')}.should raise_error(Configatron::ProtectedParameter)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should be able to unprotect a parameter" do
|
56
|
+
configatron.one = 1
|
57
|
+
configatron.protect(:one)
|
58
|
+
configatron.unprotect(:one)
|
59
|
+
lambda{configatron.one = 2}.should_not raise_error
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should be able to unprotect all parameters at once" do
|
63
|
+
configatron.one = 1
|
64
|
+
configatron.letters.a = 'A'
|
65
|
+
configatron.letters.b = 'B'
|
66
|
+
configatron.protect_all!
|
67
|
+
configatron.unprotect_all!
|
68
|
+
lambda{configatron.one = 2}.should_not raise_error
|
69
|
+
lambda{configatron.letters.configure_from_hash(:a => 'a')}.should_not raise_error
|
70
|
+
end
|
71
|
+
|
42
72
|
end
|
43
73
|
|
44
74
|
describe 'temp' 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: 2.
|
4
|
+
version: 2.1.0
|
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-
|
12
|
+
date: 2008-09-18 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|