configatron 1.2.2 → 2.0.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/README +61 -34
- data/doc/classes/Configatron.html +241 -0
- data/doc/classes/Configatron/ProtectedParameter.html +146 -0
- data/doc/classes/Configatron/Store.html +241 -121
- data/doc/classes/Kernel.html +13 -20
- data/doc/created.rid +1 -1
- data/doc/files/README.html +85 -43
- data/doc/files/lib/configatron/{configuration_rb.html → configatron_rb.html} +11 -4
- data/doc/files/lib/configatron/{helpers_rb.html → errors_rb.html} +4 -4
- 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 -2
- data/doc/fr_class_index.html +2 -4
- data/doc/fr_file_index.html +2 -3
- data/doc/fr_method_index.html +15 -21
- data/lib/configatron.rb +5 -44
- data/lib/configatron/configatron.rb +44 -0
- data/lib/configatron/errors.rb +7 -0
- data/lib/configatron/kernel.rb +3 -9
- data/lib/configatron/store.rb +148 -56
- data/spec/lib/configatron_spec.rb +293 -0
- data/spec/lib/futurama.yml +6 -0
- data/spec/spec_helper.rb +3 -2
- metadata +11 -18
- data/doc/classes/Configatron/Configuration.html +0 -402
- data/doc/classes/Configatron/Helpers.html +0 -174
- data/doc/classes/Configatron/YamlStore.html +0 -203
- data/doc/classes/Hash.html +0 -193
- data/doc/files/lib/configatron/yaml_store_rb.html +0 -101
- data/lib/configatron/configuration.rb +0 -112
- data/lib/configatron/helpers.rb +0 -27
- data/lib/configatron/yaml_store.rb +0 -33
- data/spec/unit/configuration_spec.rb +0 -299
- data/spec/unit/family_guy.yml +0 -2
- data/spec/unit/helpers_spec.rb +0 -115
- data/spec/unit/kernel_spec.rb +0 -48
- data/spec/unit/store_spec.rb +0 -91
@@ -78,12 +78,6 @@
|
|
78
78
|
|
79
79
|
<div id="contextContent">
|
80
80
|
|
81
|
-
<div id="description">
|
82
|
-
<p>
|
83
|
-
Used to store each of the ‘sets’ of configuration parameters.
|
84
|
-
</p>
|
85
|
-
|
86
|
-
</div>
|
87
81
|
|
88
82
|
|
89
83
|
</div>
|
@@ -92,12 +86,16 @@ Used to store each of the ‘sets’ of configuration parameters.
|
|
92
86
|
<h3 class="section-bar">Methods</h3>
|
93
87
|
|
94
88
|
<div class="name-list">
|
95
|
-
<a href="#
|
96
|
-
<a href="#
|
97
|
-
<a href="#
|
98
|
-
<a href="#
|
99
|
-
<a href="#
|
100
|
-
<a href="#
|
89
|
+
<a href="#M000006">configure_from_hash</a>
|
90
|
+
<a href="#M000007">configure_from_yaml</a>
|
91
|
+
<a href="#M000013">deep_clone</a>
|
92
|
+
<a href="#M000004">new</a>
|
93
|
+
<a href="#M000008">nil?</a>
|
94
|
+
<a href="#M000012">protect</a>
|
95
|
+
<a href="#M000010">remove</a>
|
96
|
+
<a href="#M000009">retrieve</a>
|
97
|
+
<a href="#M000011">set_default</a>
|
98
|
+
<a href="#M000005">to_hash</a>
|
101
99
|
</div>
|
102
100
|
</div>
|
103
101
|
|
@@ -105,13 +103,6 @@ Used to store each of the ‘sets’ of configuration parameters.
|
|
105
103
|
|
106
104
|
|
107
105
|
<!-- if includes -->
|
108
|
-
<div id="includes">
|
109
|
-
<h3 class="section-bar">Included Modules</h3>
|
110
|
-
|
111
|
-
<div id="includes-list">
|
112
|
-
<span class="include-name"><a href="Helpers.html">Configatron::Helpers</a></span>
|
113
|
-
</div>
|
114
|
-
</div>
|
115
106
|
|
116
107
|
<div id="section">
|
117
108
|
|
@@ -119,22 +110,6 @@ Used to store each of the ‘sets’ of configuration parameters.
|
|
119
110
|
|
120
111
|
|
121
112
|
|
122
|
-
<div id="attribute-list">
|
123
|
-
<h3 class="section-bar">Attributes</h3>
|
124
|
-
|
125
|
-
<div class="name-list">
|
126
|
-
<table>
|
127
|
-
<tr class="top-aligned-row context-row">
|
128
|
-
<td class="context-item-name">parameters</td>
|
129
|
-
<td class="context-item-value"> [R] </td>
|
130
|
-
<td class="context-item-desc">
|
131
|
-
The actual key/pair parameter values.
|
132
|
-
|
133
|
-
</td>
|
134
|
-
</tr>
|
135
|
-
</table>
|
136
|
-
</div>
|
137
|
-
</div>
|
138
113
|
|
139
114
|
|
140
115
|
|
@@ -142,31 +117,29 @@ The actual key/pair parameter values.
|
|
142
117
|
<div id="methods">
|
143
118
|
<h3 class="section-bar">Public Class methods</h3>
|
144
119
|
|
145
|
-
<div id="method-
|
146
|
-
<a name="
|
120
|
+
<div id="method-M000004" class="method-detail">
|
121
|
+
<a name="M000004"></a>
|
147
122
|
|
148
123
|
<div class="method-heading">
|
149
|
-
<a href="#
|
150
|
-
<span class="method-name">new</span><span class="method-args">(
|
124
|
+
<a href="#M000004" class="method-signature">
|
125
|
+
<span class="method-name">new</span><span class="method-args">(options = {})</span>
|
151
126
|
</a>
|
152
127
|
</div>
|
153
128
|
|
154
129
|
<div class="method-description">
|
155
130
|
<p>
|
156
|
-
Takes an optional
|
131
|
+
Takes an optional Hash of parameters
|
157
132
|
</p>
|
158
133
|
<p><a class="source-toggle" href="#"
|
159
|
-
onclick="toggleCode('
|
160
|
-
<div class="method-source-code" id="
|
134
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
135
|
+
<div class="method-source-code" id="M000004-source">
|
161
136
|
<pre>
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
15: <span class="ruby-keyword kw">end</span>
|
169
|
-
16: <span class="ruby-keyword kw">end</span>
|
137
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 5</span>
|
138
|
+
5: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span> = {})
|
139
|
+
6: <span class="ruby-ivar">@_store</span> = {}
|
140
|
+
7: <span class="ruby-identifier">configure_from_hash</span>(<span class="ruby-identifier">options</span>)
|
141
|
+
8: <span class="ruby-ivar">@_protected</span> = []
|
142
|
+
9: <span class="ruby-keyword kw">end</span>
|
170
143
|
</pre>
|
171
144
|
</div>
|
172
145
|
</div>
|
@@ -174,67 +147,150 @@ Takes an optional <a href="../Hash.html">Hash</a> to configure parameters.
|
|
174
147
|
|
175
148
|
<h3 class="section-bar">Public Instance methods</h3>
|
176
149
|
|
150
|
+
<div id="method-M000006" class="method-detail">
|
151
|
+
<a name="M000006"></a>
|
152
|
+
|
153
|
+
<div class="method-heading">
|
154
|
+
<a href="#M000006" class="method-signature">
|
155
|
+
<span class="method-name">configure_from_hash</span><span class="method-args">(options)</span>
|
156
|
+
</a>
|
157
|
+
</div>
|
158
|
+
|
159
|
+
<div class="method-description">
|
160
|
+
<p>
|
161
|
+
Allows for the configuration of the system via a Hash
|
162
|
+
</p>
|
163
|
+
<p><a class="source-toggle" href="#"
|
164
|
+
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
165
|
+
<div class="method-source-code" id="M000006-source">
|
166
|
+
<pre>
|
167
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 21</span>
|
168
|
+
21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure_from_hash</span>(<span class="ruby-identifier">options</span>)
|
169
|
+
22: <span class="ruby-identifier">parse_options</span>(<span class="ruby-identifier">options</span>)
|
170
|
+
23: <span class="ruby-keyword kw">end</span>
|
171
|
+
</pre>
|
172
|
+
</div>
|
173
|
+
</div>
|
174
|
+
</div>
|
175
|
+
|
177
176
|
<div id="method-M000007" class="method-detail">
|
178
177
|
<a name="M000007"></a>
|
179
178
|
|
180
179
|
<div class="method-heading">
|
181
180
|
<a href="#M000007" class="method-signature">
|
182
|
-
<span class="method-name">
|
181
|
+
<span class="method-name">configure_from_yaml</span><span class="method-args">(path)</span>
|
183
182
|
</a>
|
184
183
|
</div>
|
185
184
|
|
186
185
|
<div class="method-description">
|
187
186
|
<p>
|
188
|
-
|
187
|
+
Allows for the configuration of the system from a YAML file. Takes the path
|
188
|
+
to the YAML file.
|
189
189
|
</p>
|
190
190
|
<p><a class="source-toggle" href="#"
|
191
191
|
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
192
192
|
<div class="method-source-code" id="M000007-source">
|
193
193
|
<pre>
|
194
|
-
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
194
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 27</span>
|
195
|
+
27: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">configure_from_yaml</span>(<span class="ruby-identifier">path</span>)
|
196
|
+
28: <span class="ruby-keyword kw">begin</span>
|
197
|
+
29: <span class="ruby-identifier">configure_from_hash</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>)))
|
198
|
+
30: <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">></span> <span class="ruby-identifier">e</span>
|
199
|
+
31: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
|
200
|
+
32: <span class="ruby-keyword kw">end</span>
|
201
|
+
33: <span class="ruby-keyword kw">end</span>
|
199
202
|
</pre>
|
200
203
|
</div>
|
201
204
|
</div>
|
202
205
|
</div>
|
203
206
|
|
204
|
-
<div id="method-
|
205
|
-
<a name="
|
207
|
+
<div id="method-M000013" class="method-detail">
|
208
|
+
<a name="M000013"></a>
|
206
209
|
|
207
210
|
<div class="method-heading">
|
208
|
-
<a href="#
|
209
|
-
<span class="method-name">
|
211
|
+
<a href="#M000013" class="method-signature">
|
212
|
+
<span class="method-name">deep_clone</span><span class="method-args">( obj=self, cloned={} )</span>
|
210
213
|
</a>
|
211
214
|
</div>
|
212
215
|
|
213
216
|
<div class="method-description">
|
214
|
-
<
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
217
|
+
<h1>DeepClone</h1>
|
218
|
+
<h2>Version</h2>
|
219
|
+
<pre>
|
220
|
+
1.2006.05.23 (change of the first number means Big Change)
|
221
|
+
</pre>
|
222
|
+
<h2>Description</h2>
|
223
|
+
<pre>
|
224
|
+
Adds deep_clone method to an object which produces deep copy of it. It means
|
225
|
+
if you clone a Hash, every nested items and their nested items will be cloned.
|
226
|
+
Moreover deep_clone checks if the object is already cloned to prevent endless recursion.
|
227
|
+
</pre>
|
228
|
+
<h2>Usage</h2>
|
229
|
+
<pre>
|
230
|
+
(see examples directory under the ruby gems root directory)
|
231
|
+
|
232
|
+
require 'rubygems'
|
233
|
+
require 'deep_clone'
|
234
|
+
|
235
|
+
include DeepClone
|
236
|
+
|
237
|
+
obj = []
|
238
|
+
a = [ true, false, obj ]
|
239
|
+
b = a.deep_clone
|
240
|
+
obj.push( 'foo' )
|
241
|
+
p obj # >> [ 'foo' ]
|
242
|
+
p b[2] # >> []
|
243
|
+
</pre>
|
244
|
+
<h2>Source</h2>
|
245
|
+
<p>
|
246
|
+
<a
|
247
|
+
href="http://simplypowerful.1984.cz/goodlibs/1.2006.05.23">simplypowerful.1984.cz/goodlibs/1.2006.05.23</a>
|
220
248
|
</p>
|
249
|
+
<h2>Author</h2>
|
250
|
+
<pre>
|
251
|
+
jan molic (/mig/at_sign/1984/dot/cz/)
|
252
|
+
</pre>
|
253
|
+
<h2>Licence</h2>
|
254
|
+
<pre>
|
255
|
+
You can redistribute it and/or modify it under the same terms of Ruby's license;
|
256
|
+
either the dual license version in 2003, or any later version.
|
257
|
+
</pre>
|
221
258
|
<p><a class="source-toggle" href="#"
|
222
|
-
onclick="toggleCode('
|
223
|
-
<div class="method-source-code" id="
|
259
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
260
|
+
<div class="method-source-code" id="M000013-source">
|
224
261
|
<pre>
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
262
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 118</span>
|
263
|
+
118: <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>={} )
|
264
|
+
119: <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> )
|
265
|
+
120: <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>]
|
266
|
+
121: <span class="ruby-keyword kw">else</span>
|
267
|
+
122: <span class="ruby-keyword kw">begin</span>
|
268
|
+
123: <span class="ruby-identifier">cl</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">clone</span>
|
269
|
+
124: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
|
270
|
+
125: <span class="ruby-comment cmt"># unclonnable (TrueClass, Fixnum, ...)</span>
|
271
|
+
126: <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>
|
272
|
+
127: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">obj</span>
|
273
|
+
128: <span class="ruby-keyword kw">else</span>
|
274
|
+
129: <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>
|
275
|
+
130: <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>
|
276
|
+
131: <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> )
|
277
|
+
132: <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>
|
278
|
+
133: <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> )
|
279
|
+
134: }
|
280
|
+
135: <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> )
|
281
|
+
136: <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>
|
282
|
+
137: <span class="ruby-identifier">deep_clone</span>( <span class="ruby-identifier">v</span>, <span class="ruby-identifier">cloned</span> )
|
283
|
+
138: }
|
284
|
+
139: <span class="ruby-keyword kw">end</span>
|
285
|
+
140: <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>
|
286
|
+
141: <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> )
|
287
|
+
142: <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> )
|
288
|
+
143: <span class="ruby-identifier">cl</span>.<span class="ruby-identifier">instance_eval</span>( <span class="ruby-node">"#{var} = v_cl"</span> )
|
289
|
+
144: <span class="ruby-keyword kw">end</span>
|
290
|
+
145: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">cl</span>
|
291
|
+
146: <span class="ruby-keyword kw">end</span>
|
292
|
+
147: <span class="ruby-keyword kw">end</span>
|
293
|
+
148: <span class="ruby-keyword kw">end</span>
|
238
294
|
</pre>
|
239
295
|
</div>
|
240
296
|
</div>
|
@@ -245,31 +301,72 @@ from the parameters hash is returned, if it exists.
|
|
245
301
|
|
246
302
|
<div class="method-heading">
|
247
303
|
<a href="#M000008" class="method-signature">
|
248
|
-
<span class="method-name">
|
304
|
+
<span class="method-name">nil?</span><span class="method-args">()</span>
|
249
305
|
</a>
|
250
306
|
</div>
|
251
307
|
|
252
308
|
<div class="method-description">
|
253
309
|
<p>
|
254
|
-
|
255
|
-
parameters.
|
310
|
+
Returns true if there are no configuration parameters
|
256
311
|
</p>
|
257
312
|
<p><a class="source-toggle" href="#"
|
258
313
|
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
259
314
|
<div class="method-source-code" id="M000008-source">
|
260
315
|
<pre>
|
261
|
-
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
316
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 36</span>
|
317
|
+
36: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">nil?</span>
|
318
|
+
37: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@_store</span>.<span class="ruby-identifier">empty?</span>
|
319
|
+
38: <span class="ruby-keyword kw">end</span>
|
320
|
+
</pre>
|
321
|
+
</div>
|
322
|
+
</div>
|
323
|
+
</div>
|
324
|
+
|
325
|
+
<div id="method-M000012" class="method-detail">
|
326
|
+
<a name="M000012"></a>
|
327
|
+
|
328
|
+
<div class="method-heading">
|
329
|
+
<a href="#M000012" class="method-signature">
|
330
|
+
<span class="method-name">protect</span><span class="method-args">(name)</span>
|
331
|
+
</a>
|
332
|
+
</div>
|
333
|
+
|
334
|
+
<div class="method-description">
|
335
|
+
<p><a class="source-toggle" href="#"
|
336
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
337
|
+
<div class="method-source-code" id="M000012-source">
|
338
|
+
<pre>
|
339
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 78</span>
|
340
|
+
78: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">protect</span>(<span class="ruby-identifier">name</span>)
|
341
|
+
79: <span class="ruby-ivar">@_protected</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>
|
342
|
+
80: <span class="ruby-keyword kw">end</span>
|
343
|
+
</pre>
|
344
|
+
</div>
|
345
|
+
</div>
|
346
|
+
</div>
|
347
|
+
|
348
|
+
<div id="method-M000010" class="method-detail">
|
349
|
+
<a name="M000010"></a>
|
350
|
+
|
351
|
+
<div class="method-heading">
|
352
|
+
<a href="#M000010" class="method-signature">
|
353
|
+
<span class="method-name">remove</span><span class="method-args">(name)</span>
|
354
|
+
</a>
|
355
|
+
</div>
|
356
|
+
|
357
|
+
<div class="method-description">
|
358
|
+
<p>
|
359
|
+
Removes a parameter. In the case of a nested parameter it will <a
|
360
|
+
href="Store.html#M000010">remove</a> all below it.
|
361
|
+
</p>
|
362
|
+
<p><a class="source-toggle" href="#"
|
363
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
364
|
+
<div class="method-source-code" id="M000010-source">
|
365
|
+
<pre>
|
366
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 48</span>
|
367
|
+
48: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove</span>(<span class="ruby-identifier">name</span>)
|
368
|
+
49: <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>)
|
369
|
+
50: <span class="ruby-keyword kw">end</span>
|
273
370
|
</pre>
|
274
371
|
</div>
|
275
372
|
</div>
|
@@ -280,55 +377,78 @@ parameters.
|
|
280
377
|
|
281
378
|
<div class="method-heading">
|
282
379
|
<a href="#M000009" class="method-signature">
|
283
|
-
<span class="method-name">
|
380
|
+
<span class="method-name">retrieve</span><span class="method-args">(name, default_value = nil)</span>
|
284
381
|
</a>
|
285
382
|
</div>
|
286
383
|
|
287
384
|
<div class="method-description">
|
288
385
|
<p>
|
289
|
-
|
290
|
-
|
291
|
-
etc…
|
386
|
+
Retrieves a certain parameter and if that parameter doesn‘t exist it
|
387
|
+
will return the default_value specified.
|
292
388
|
</p>
|
293
389
|
<p><a class="source-toggle" href="#"
|
294
390
|
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
295
391
|
<div class="method-source-code" id="M000009-source">
|
296
392
|
<pre>
|
297
|
-
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line
|
298
|
-
|
393
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 42</span>
|
394
|
+
42: <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>)
|
395
|
+
43: <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>
|
396
|
+
44: <span class="ruby-keyword kw">end</span>
|
397
|
+
</pre>
|
398
|
+
</div>
|
399
|
+
</div>
|
400
|
+
</div>
|
401
|
+
|
402
|
+
<div id="method-M000011" class="method-detail">
|
403
|
+
<a name="M000011"></a>
|
404
|
+
|
405
|
+
<div class="method-heading">
|
406
|
+
<a href="#M000011" class="method-signature">
|
407
|
+
<span class="method-name">set_default</span><span class="method-args">(name, default_value)</span>
|
408
|
+
</a>
|
409
|
+
</div>
|
410
|
+
|
411
|
+
<div class="method-description">
|
412
|
+
<p>
|
413
|
+
Sets a ‘default’ value. If there is already a value specified
|
414
|
+
it won‘t set the value.
|
415
|
+
</p>
|
416
|
+
<p><a class="source-toggle" href="#"
|
417
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
418
|
+
<div class="method-source-code" id="M000011-source">
|
419
|
+
<pre>
|
420
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 54</span>
|
421
|
+
54: <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>)
|
422
|
+
55: <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>]
|
423
|
+
56: <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>)
|
424
|
+
57: <span class="ruby-keyword kw">end</span>
|
299
425
|
58: <span class="ruby-keyword kw">end</span>
|
300
426
|
</pre>
|
301
427
|
</div>
|
302
428
|
</div>
|
303
429
|
</div>
|
304
430
|
|
305
|
-
<div id="method-
|
306
|
-
<a name="
|
431
|
+
<div id="method-M000005" class="method-detail">
|
432
|
+
<a name="M000005"></a>
|
307
433
|
|
308
434
|
<div class="method-heading">
|
309
|
-
<a href="#
|
435
|
+
<a href="#M000005" class="method-signature">
|
310
436
|
<span class="method-name">to_hash</span><span class="method-args">()</span>
|
311
437
|
</a>
|
312
438
|
</div>
|
313
439
|
|
314
440
|
<div class="method-description">
|
441
|
+
<p>
|
442
|
+
Returns a Hash representing the configurations
|
443
|
+
</p>
|
315
444
|
<p><a class="source-toggle" href="#"
|
316
|
-
onclick="toggleCode('
|
317
|
-
<div class="method-source-code" id="
|
445
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
446
|
+
<div class="method-source-code" id="M000005-source">
|
318
447
|
<pre>
|
319
|
-
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
63: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Configatron</span><span class="ruby-operator">::</span><span class="ruby-constant">Store</span>
|
324
|
-
64: <span class="ruby-identifier">acc</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_hash</span>
|
325
|
-
65: <span class="ruby-keyword kw">else</span>
|
326
|
-
66: <span class="ruby-identifier">acc</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
|
327
|
-
67: <span class="ruby-keyword kw">end</span>
|
328
|
-
68:
|
329
|
-
69: <span class="ruby-identifier">acc</span>
|
330
|
-
70: <span class="ruby-keyword kw">end</span>
|
331
|
-
71: <span class="ruby-keyword kw">end</span>
|
448
|
+
<span class="ruby-comment cmt"># File lib/configatron/store.rb, line 12</span>
|
449
|
+
12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>
|
450
|
+
13: <span class="ruby-ivar">@_store</span>
|
451
|
+
14: <span class="ruby-keyword kw">end</span>
|
332
452
|
</pre>
|
333
453
|
</div>
|
334
454
|
</div>
|