configatron 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -137,12 +137,13 @@ Takes an optional Hash of parameters
137
137
  onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
138
138
  <div class="method-source-code" id="M000004-source">
139
139
  <pre>
140
- <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 5</span>
141
- 5: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span> = {})
142
- 6: <span class="ruby-ivar">@_store</span> = {}
143
- 7: <span class="ruby-identifier">configure_from_hash</span>(<span class="ruby-identifier">options</span>)
144
- 8: <span class="ruby-ivar">@_protected</span> = []
145
- 9: <span class="ruby-keyword kw">end</span>
140
+ <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 5</span>
141
+ 5: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span> = {})
142
+ 6: <span class="ruby-ivar">@_store</span> = {}
143
+ 7: <span class="ruby-identifier">configure_from_hash</span>(<span class="ruby-identifier">options</span>)
144
+ 8: <span class="ruby-ivar">@_protected</span> = []
145
+ 9: <span class="ruby-comment cmt"># self.methods.each { |m| puts &quot;m: #{m}&quot;; configatron.protect(m.to_sym) }</span>
146
+ 10: <span class="ruby-keyword kw">end</span>
146
147
  </pre>
147
148
  </div>
148
149
  </div>
@@ -167,10 +168,10 @@ Allows for the configuration of the system via a Hash
167
168
  onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
168
169
  <div class="method-source-code" id="M000006-source">
169
170
  <pre>
170
- <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 21</span>
171
- 21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure_from_hash</span>(<span class="ruby-identifier">options</span>)
172
- 22: <span class="ruby-identifier">parse_options</span>(<span class="ruby-identifier">options</span>)
173
- 23: <span class="ruby-keyword kw">end</span>
171
+ <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 22</span>
172
+ 22: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure_from_hash</span>(<span class="ruby-identifier">options</span>)
173
+ 23: <span class="ruby-identifier">parse_options</span>(<span class="ruby-identifier">options</span>)
174
+ 24: <span class="ruby-keyword kw">end</span>
174
175
  </pre>
175
176
  </div>
176
177
  </div>
@@ -195,16 +196,16 @@ indicates a specific hash that should be loaded from the file.
195
196
  onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
196
197
  <div class="method-source-code" id="M000007-source">
197
198
  <pre>
198
- <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 29</span>
199
- 29: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure_from_yaml</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">opts</span> = {})
200
- 30: <span class="ruby-keyword kw">begin</span>
201
- 31: <span class="ruby-identifier">yml</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">path</span>))
202
- 32: <span class="ruby-identifier">yml</span> = <span class="ruby-identifier">yml</span>[<span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:hash</span>]] <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:hash</span>].<span class="ruby-identifier">nil?</span>
203
- 33: <span class="ruby-identifier">configure_from_hash</span>(<span class="ruby-identifier">yml</span>)
204
- 34: <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>
205
- 35: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
206
- 36: <span class="ruby-keyword kw">end</span>
207
- 37: <span class="ruby-keyword kw">end</span>
199
+ <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 30</span>
200
+ 30: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure_from_yaml</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">opts</span> = {})
201
+ 31: <span class="ruby-keyword kw">begin</span>
202
+ 32: <span class="ruby-identifier">yml</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">path</span>))
203
+ 33: <span class="ruby-identifier">yml</span> = <span class="ruby-identifier">yml</span>[<span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:hash</span>]] <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:hash</span>].<span class="ruby-identifier">nil?</span>
204
+ 34: <span class="ruby-identifier">configure_from_hash</span>(<span class="ruby-identifier">yml</span>)
205
+ 35: <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>
206
+ 36: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
207
+ 37: <span class="ruby-keyword kw">end</span>
208
+ 38: <span class="ruby-keyword kw">end</span>
208
209
  </pre>
209
210
  </div>
210
211
  </div>
@@ -265,38 +266,38 @@ href="http://simplypowerful.1984.cz/goodlibs/1.2006.05.23">simplypowerful.1984.c
265
266
  onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
266
267
  <div class="method-source-code" id="M000016-source">
267
268
  <pre>
268
- <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 147</span>
269
- 147: <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>={} )
270
- 148: <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> )
271
- 149: <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>]
272
- 150: <span class="ruby-keyword kw">else</span>
273
- 151: <span class="ruby-keyword kw">begin</span>
274
- 152: <span class="ruby-identifier">cl</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">clone</span>
275
- 153: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
276
- 154: <span class="ruby-comment cmt"># unclonnable (TrueClass, Fixnum, ...)</span>
277
- 155: <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>
278
- 156: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">obj</span>
279
- 157: <span class="ruby-keyword kw">else</span>
280
- 158: <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>
281
- 159: <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>
282
- 160: <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> )
283
- 161: <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>
284
- 162: <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> )
285
- 163: }
286
- 164: <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> )
287
- 165: <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>
288
- 166: <span class="ruby-identifier">deep_clone</span>( <span class="ruby-identifier">v</span>, <span class="ruby-identifier">cloned</span> )
289
- 167: }
290
- 168: <span class="ruby-keyword kw">end</span>
291
- 169: <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>
292
- 170: <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> )
293
- 171: <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> )
294
- 172: <span class="ruby-identifier">cl</span>.<span class="ruby-identifier">instance_eval</span>( <span class="ruby-node">&quot;#{var} = v_cl&quot;</span> )
295
- 173: <span class="ruby-keyword kw">end</span>
296
- 174: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">cl</span>
297
- 175: <span class="ruby-keyword kw">end</span>
298
- 176: <span class="ruby-keyword kw">end</span>
299
- 177: <span class="ruby-keyword kw">end</span>
269
+ <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 148</span>
270
+ 148: <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>={} )
271
+ 149: <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> )
272
+ 150: <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>]
273
+ 151: <span class="ruby-keyword kw">else</span>
274
+ 152: <span class="ruby-keyword kw">begin</span>
275
+ 153: <span class="ruby-identifier">cl</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">clone</span>
276
+ 154: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
277
+ 155: <span class="ruby-comment cmt"># unclonnable (TrueClass, Fixnum, ...)</span>
278
+ 156: <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>
279
+ 157: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">obj</span>
280
+ 158: <span class="ruby-keyword kw">else</span>
281
+ 159: <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>
282
+ 160: <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>
283
+ 161: <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> )
284
+ 162: <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>
285
+ 163: <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> )
286
+ 164: }
287
+ 165: <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> )
288
+ 166: <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>
289
+ 167: <span class="ruby-identifier">deep_clone</span>( <span class="ruby-identifier">v</span>, <span class="ruby-identifier">cloned</span> )
290
+ 168: }
291
+ 169: <span class="ruby-keyword kw">end</span>
292
+ 170: <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>
293
+ 171: <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> )
294
+ 172: <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> )
295
+ 173: <span class="ruby-identifier">cl</span>.<span class="ruby-identifier">instance_eval</span>( <span class="ruby-node">&quot;#{var} = v_cl&quot;</span> )
296
+ 174: <span class="ruby-keyword kw">end</span>
297
+ 175: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">cl</span>
298
+ 176: <span class="ruby-keyword kw">end</span>
299
+ 177: <span class="ruby-keyword kw">end</span>
300
+ 178: <span class="ruby-keyword kw">end</span>
300
301
  </pre>
301
302
  </div>
302
303
  </div>
@@ -319,10 +320,10 @@ Returns true if there are no configuration parameters
319
320
  onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
320
321
  <div class="method-source-code" id="M000008-source">
321
322
  <pre>
322
- <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 40</span>
323
- 40: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">nil?</span>
324
- 41: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@_store</span>.<span class="ruby-identifier">empty?</span>
325
- 42: <span class="ruby-keyword kw">end</span>
323
+ <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 41</span>
324
+ 41: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">nil?</span>
325
+ 42: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@_store</span>.<span class="ruby-identifier">empty?</span>
326
+ 43: <span class="ruby-keyword kw">end</span>
326
327
  </pre>
327
328
  </div>
328
329
  </div>
@@ -347,10 +348,10 @@ well.
347
348
  onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
348
349
  <div class="method-source-code" id="M000012-source">
349
350
  <pre>
350
- <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 84</span>
351
- 84: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">protect</span>(<span class="ruby-identifier">name</span>)
352
- 85: <span class="ruby-ivar">@_protected</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>
353
- 86: <span class="ruby-keyword kw">end</span>
351
+ <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 85</span>
352
+ 85: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">protect</span>(<span class="ruby-identifier">name</span>)
353
+ 86: <span class="ruby-ivar">@_protected</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>
354
+ 87: <span class="ruby-keyword kw">end</span>
354
355
  </pre>
355
356
  </div>
356
357
  </div>
@@ -373,15 +374,15 @@ Prevents all parameters from being reassigned.
373
374
  onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
374
375
  <div class="method-source-code" id="M000013-source">
375
376
  <pre>
376
- <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 89</span>
377
- 89: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">protect_all!</span>
378
- 90: <span class="ruby-ivar">@_protected</span>.<span class="ruby-identifier">clear</span>
379
- 91: <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>
380
- 92: <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>)
381
- 93: <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>
382
- 94: <span class="ruby-ivar">@_protected</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">k</span>
383
- 95: <span class="ruby-keyword kw">end</span>
384
- 96: <span class="ruby-keyword kw">end</span>
377
+ <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 90</span>
378
+ 90: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">protect_all!</span>
379
+ 91: <span class="ruby-ivar">@_protected</span>.<span class="ruby-identifier">clear</span>
380
+ 92: <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>
381
+ 93: <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>)
382
+ 94: <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>
383
+ 95: <span class="ruby-ivar">@_protected</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">k</span>
384
+ 96: <span class="ruby-keyword kw">end</span>
385
+ 97: <span class="ruby-keyword kw">end</span>
385
386
  </pre>
386
387
  </div>
387
388
  </div>
@@ -405,10 +406,10 @@ href="Store.html#M000010">remove</a> all below it.
405
406
  onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
406
407
  <div class="method-source-code" id="M000010-source">
407
408
  <pre>
408
- <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 52</span>
409
- 52: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove</span>(<span class="ruby-identifier">name</span>)
410
- 53: <span class="ruby-ivar">@_store</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>)
411
- 54: <span class="ruby-keyword kw">end</span>
409
+ <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 53</span>
410
+ 53: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove</span>(<span class="ruby-identifier">name</span>)
411
+ 54: <span class="ruby-ivar">@_store</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>)
412
+ 55: <span class="ruby-keyword kw">end</span>
412
413
  </pre>
413
414
  </div>
414
415
  </div>
@@ -432,10 +433,10 @@ will return the default_value specified.
432
433
  onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
433
434
  <div class="method-source-code" id="M000009-source">
434
435
  <pre>
435
- <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 46</span>
436
- 46: <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-keyword kw">nil</span>)
437
- 47: <span class="ruby-ivar">@_store</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">default_value</span>
438
- 48: <span class="ruby-keyword kw">end</span>
436
+ <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 47</span>
437
+ 47: <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-keyword kw">nil</span>)
438
+ 48: <span class="ruby-ivar">@_store</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">default_value</span>
439
+ 49: <span class="ruby-keyword kw">end</span>
439
440
  </pre>
440
441
  </div>
441
442
  </div>
@@ -459,12 +460,12 @@ it won&#8216;t set the value.
459
460
  onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
460
461
  <div class="method-source-code" id="M000011-source">
461
462
  <pre>
462
- <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 58</span>
463
- 58: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_default</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">default_value</span>)
464
- 59: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@_store</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>]
465
- 60: <span class="ruby-ivar">@_store</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>] = <span class="ruby-identifier">parse_options</span>(<span class="ruby-identifier">default_value</span>)
466
- 61: <span class="ruby-keyword kw">end</span>
467
- 62: <span class="ruby-keyword kw">end</span>
463
+ <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 59</span>
464
+ 59: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_default</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">default_value</span>)
465
+ 60: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@_store</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>]
466
+ 61: <span class="ruby-ivar">@_store</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>] = <span class="ruby-identifier">parse_options</span>(<span class="ruby-identifier">default_value</span>)
467
+ 62: <span class="ruby-keyword kw">end</span>
468
+ 63: <span class="ruby-keyword kw">end</span>
468
469
  </pre>
469
470
  </div>
470
471
  </div>
@@ -487,10 +488,10 @@ Returns a Hash representing the configurations
487
488
  onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
488
489
  <div class="method-source-code" id="M000005-source">
489
490
  <pre>
490
- <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 12</span>
491
- 12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>
492
- 13: <span class="ruby-ivar">@_store</span>
493
- 14: <span class="ruby-keyword kw">end</span>
491
+ <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 13</span>
492
+ 13: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>
493
+ 14: <span class="ruby-ivar">@_store</span>
494
+ 15: <span class="ruby-keyword kw">end</span>
494
495
  </pre>
495
496
  </div>
496
497
  </div>
@@ -513,10 +514,10 @@ Removes the protection of a parameter.
513
514
  onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
514
515
  <div class="method-source-code" id="M000014-source">
515
516
  <pre>
516
- <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 99</span>
517
- 99: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unprotect</span>(<span class="ruby-identifier">name</span>)
518
- 100: <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> }
519
- 101: <span class="ruby-keyword kw">end</span>
517
+ <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 100</span>
518
+ 100: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unprotect</span>(<span class="ruby-identifier">name</span>)
519
+ 101: <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> }
520
+ 102: <span class="ruby-keyword kw">end</span>
520
521
  </pre>
521
522
  </div>
522
523
  </div>
@@ -536,14 +537,14 @@ Removes the protection of a parameter.
536
537
  onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
537
538
  <div class="method-source-code" id="M000015-source">
538
539
  <pre>
539
- <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 103</span>
540
- 103: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unprotect_all!</span>
541
- 104: <span class="ruby-ivar">@_protected</span>.<span class="ruby-identifier">clear</span>
542
- 105: <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>
543
- 106: <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>)
544
- 107: <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>
545
- 108: <span class="ruby-keyword kw">end</span>
546
- 109: <span class="ruby-keyword kw">end</span>
540
+ <span class="ruby-comment cmt"># File lib/configatron/store.rb, line 104</span>
541
+ 104: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unprotect_all!</span>
542
+ 105: <span class="ruby-ivar">@_protected</span>.<span class="ruby-identifier">clear</span>
543
+ 106: <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>
544
+ 107: <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>)
545
+ 108: <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>
546
+ 109: <span class="ruby-keyword kw">end</span>
547
+ 110: <span class="ruby-keyword kw">end</span>
547
548
  </pre>
548
549
  </div>
549
550
  </div>
data/doc/created.rid CHANGED
@@ -1 +1 @@
1
- Thu, 18 Sep 2008 13:09:10 -0400
1
+ Sun, 28 Sep 2008 21:23:52 -0400
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Thu Sep 18 12:34:39 -0400 2008</td>
59
+ <td>Wed Sep 17 14:47:44 -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>Thu Sep 18 12:34:39 -0400 2008</td>
59
+ <td>Wed Sep 17 15:15:24 -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>Thu Sep 18 12:34:39 -0400 2008</td>
59
+ <td>Wed Sep 17 15:16:26 -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>Thu Sep 18 12:34:39 -0400 2008</td>
59
+ <td>Wed Sep 17 14:47:44 -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>Thu Sep 18 13:08:55 -0400 2008</td>
59
+ <td>Sun Sep 28 21:23:06 -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>Thu Sep 18 12:34:39 -0400 2008</td>
59
+ <td>Sun Sep 28 21:23:20 -0400 2008</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -6,6 +6,7 @@ class Configatron
6
6
  @_store = {}
7
7
  configure_from_hash(options)
8
8
  @_protected = []
9
+ # self.methods.each { |m| puts "m: #{m}"; configatron.protect(m.to_sym) }
9
10
  end
10
11
 
11
12
  # Returns a Hash representing the configurations
@@ -64,7 +65,7 @@ class Configatron
64
65
  def method_missing(sym, *args) # :nodoc:
65
66
  if sym.to_s.match(/(.+)=$/)
66
67
  name = sym.to_s.gsub("=", '').to_sym
67
- raise Configatron::ProtectedParameter.new(name) if @_protected.include?(name)
68
+ raise Configatron::ProtectedParameter.new(name) if @_protected.include?(name) || self.methods.include?(name.to_s)
68
69
  @_store[name] = parse_options(*args)
69
70
  elsif @_store.has_key?(sym)
70
71
  return @_store[sym]
@@ -15,6 +15,11 @@ describe "configatron" do
15
15
  configatron.one.should == 1
16
16
  end
17
17
 
18
+ it 'should protect basic methods' do
19
+ lambda{configatron.object_id = 123456}.should raise_error(Configatron::ProtectedParameter)
20
+ lambda{configatron.foo.object_id = 123456}.should raise_error(Configatron::ProtectedParameter)
21
+ end
22
+
18
23
  it 'should work with nested parameters' do
19
24
  configatron.one = 1
20
25
  configatron.letters.a = 'A'
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.1.1
4
+ version: 2.1.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-18 00:00:00 -04:00
12
+ date: 2008-09-28 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15