cascading-configuration-array 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +369 -0
- data/README.rdoc +29 -113
- data/lib/cascading-configuration-array/CascadingConfiguration/Array/Accessors.rb +54 -0
- data/lib/cascading-configuration-array/CascadingConfiguration/{ConfigurationSettingsArray → Array}/ClassInstance.rb +5 -3
- data/lib/cascading-configuration-array/CascadingConfiguration/{ConfigurationSettingsArray → Array}/ModuleInstance.rb +7 -4
- data/lib/cascading-configuration-array/CascadingConfiguration/Array.rb +33 -0
- data/lib/cascading-configuration-array/CascadingConfiguration/{CascadingCompositeArray → CompositingArray}/Instance.rb +4 -2
- data/lib/cascading-configuration-array/CascadingConfiguration/{CascadingCompositeArray → CompositingArray}/_private_/Instance.rb +1 -1
- data/lib/cascading-configuration-array/CascadingConfiguration/{CascadingCompositeArray.rb → CompositingArray.rb} +3 -3
- data/lib/cascading-configuration-array/CascadingConfiguration/{ConfigurationArray.rb → LocalConfigurationArray.rb} +2 -2
- data/lib/cascading-configuration-array/CascadingConfiguration/_private_/{CascadingCompositeArray.rb → CompositingArray.rb} +1 -1
- data/lib/cascading-configuration-array/CascadingConfiguration/_private_/{ConfigurationArray.rb → LocalConfigurationArray.rb} +1 -1
- data/lib/cascading-configuration-array.rb +18 -15
- data/spec/CascadingConfiguration/Array/Accessors_spec.rb +28 -0
- data/spec/CascadingConfiguration/{ConfigurationSettingsArray_spec.rb → Array_spec.rb} +20 -20
- data/spec/CascadingConfiguration/{CascadingCompositeArray_spec.rb → CompositingArray_spec.rb} +89 -89
- data/spec/CascadingConfiguration/{ConfigurationArray_spec.rb → LocalConfigurationArray_spec.rb} +12 -12
- metadata +18 -17
- data/lib/cascading-configuration-array/CascadingConfiguration/ConfigurationSettingsArray/Accessors.rb +0 -41
- data/lib/cascading-configuration-array/CascadingConfiguration/ConfigurationSettingsArray.rb +0 -21
- data/spec/CascadingConfiguration/ConfigurationSettingsArray/Accessors_spec.rb +0 -28
data/README.md
ADDED
@@ -0,0 +1,369 @@
|
|
1
|
+
# Cascading Configuration #
|
2
|
+
|
3
|
+
http://rubygems.org/gems/cascading-configuration-array
|
4
|
+
|
5
|
+
# Description #
|
6
|
+
|
7
|
+
Adds methods for cascading configuration arrays. Support package for cascading-configuration.
|
8
|
+
|
9
|
+
# Summary #
|
10
|
+
|
11
|
+
## :attr_configuration_array ##
|
12
|
+
|
13
|
+
:attr_configuration_array provides inheritable configuration that cascades downward.
|
14
|
+
|
15
|
+
Configuration inheritance can cascade through modules, classes, and instances.
|
16
|
+
|
17
|
+
:attr_configuration_array defines a single attribute accessor that composes the set of configuration values appropriate to the ancestor level being queried (merging downward from most distant ancestor to self). An internal cache is kept, and any configuration updates that occur to higher-level ancestors cascade immediately downward.
|
18
|
+
|
19
|
+
The array maintained by :attr_configuration_array is kept ordered and unique.
|
20
|
+
|
21
|
+
# Install #
|
22
|
+
|
23
|
+
* sudo gem install cascading-configuration-array
|
24
|
+
|
25
|
+
# Usage #
|
26
|
+
|
27
|
+
## First Module ##
|
28
|
+
|
29
|
+
1. Define initial configuration in a module.
|
30
|
+
|
31
|
+
A class works just as well, but we can't use a module in the same chain if we start with a class.
|
32
|
+
|
33
|
+
* Include module to enable attr_configuration_array.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
|
37
|
+
module CascadingConfiguration::MockModule
|
38
|
+
include CascadingConfiguration::Array
|
39
|
+
end
|
40
|
+
|
41
|
+
```
|
42
|
+
|
43
|
+
* Declare attr_configuration_array.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
|
47
|
+
module CascadingConfiguration::MockModule
|
48
|
+
attr_configuration_array :some_array_configuration
|
49
|
+
end
|
50
|
+
|
51
|
+
```
|
52
|
+
|
53
|
+
* Set initial value.
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
|
57
|
+
module CascadingConfiguration::MockModule
|
58
|
+
self.some_array_configuration = [ :some_value ]
|
59
|
+
end
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
* Verify initial configuration value
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
|
67
|
+
module CascadingConfiguration::MockModule
|
68
|
+
|
69
|
+
# => some_array_configuration.should == [ :some_value ]
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
## Including Module 1 ##
|
76
|
+
|
77
|
+
2. Include initial module in another module.
|
78
|
+
|
79
|
+
Including the module that has included a CascadingConfiguration module is the same as including a CascadingConfiguration module.
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
|
83
|
+
module CascadingConfiguration::MockModule2
|
84
|
+
include CascadingConfiguration::MockModule
|
85
|
+
end
|
86
|
+
|
87
|
+
```
|
88
|
+
|
89
|
+
* Verify inherited value
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
|
93
|
+
module CascadingConfiguration::MockModule2
|
94
|
+
# => some_array_configuration.should == [ :some_value ]
|
95
|
+
end
|
96
|
+
|
97
|
+
```
|
98
|
+
|
99
|
+
* Override inherited value
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
|
103
|
+
module CascadingConfiguration::MockModule2
|
104
|
+
self.some_array_configuration = [ :module_value ]
|
105
|
+
end
|
106
|
+
|
107
|
+
```
|
108
|
+
|
109
|
+
* Verify local override value
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
|
113
|
+
module CascadingConfiguration::MockModule2
|
114
|
+
# => some_array_configuration.should == [ :module_value ]
|
115
|
+
end
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
## Including Module 2 ##
|
120
|
+
|
121
|
+
3. Include second module in another module.
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
|
125
|
+
module CascadingConfiguration::MockModule3
|
126
|
+
include CascadingConfiguration::MockModule2
|
127
|
+
end
|
128
|
+
|
129
|
+
```
|
130
|
+
|
131
|
+
* Verify inherited value
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
|
135
|
+
module CascadingConfiguration::MockModule3
|
136
|
+
# => some_array_configuration.should == [ :module_value ]
|
137
|
+
end
|
138
|
+
|
139
|
+
```
|
140
|
+
|
141
|
+
## Top Class ##
|
142
|
+
|
143
|
+
4. Include third module in a class.
|
144
|
+
|
145
|
+
```ruby
|
146
|
+
|
147
|
+
class CascadingConfiguration::MockClass
|
148
|
+
include CascadingConfiguration::MockModule3
|
149
|
+
end
|
150
|
+
|
151
|
+
```
|
152
|
+
|
153
|
+
* Verify inherited value
|
154
|
+
|
155
|
+
```ruby
|
156
|
+
|
157
|
+
class CascadingConfiguration::MockClass
|
158
|
+
# => some_array_configuration.should == [ :module_value ]
|
159
|
+
end
|
160
|
+
|
161
|
+
```
|
162
|
+
|
163
|
+
* Override inherited value
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
|
167
|
+
class CascadingConfiguration::MockClass
|
168
|
+
self.some_array_configuration = [ :another_value ]
|
169
|
+
end
|
170
|
+
|
171
|
+
```
|
172
|
+
|
173
|
+
* Verify local override value
|
174
|
+
|
175
|
+
```ruby
|
176
|
+
|
177
|
+
class CascadingConfiguration::MockClass
|
178
|
+
# => some_array_configuration.should == [ :another_value ]
|
179
|
+
end
|
180
|
+
|
181
|
+
```
|
182
|
+
|
183
|
+
## Instance of Top Class ##
|
184
|
+
|
185
|
+
5. Instantiate class.
|
186
|
+
|
187
|
+
```ruby
|
188
|
+
|
189
|
+
object_instance_one = CascadingConfiguration::MockClass.new
|
190
|
+
|
191
|
+
```
|
192
|
+
|
193
|
+
* Verify inherited value
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
|
197
|
+
# => object_instance_one.some_array_configuration.should == [ :another_value ]
|
198
|
+
|
199
|
+
```
|
200
|
+
|
201
|
+
* Override inherited value
|
202
|
+
|
203
|
+
```ruby
|
204
|
+
|
205
|
+
object_instance_one.some_array_configuration = [ :yet_another_value ]
|
206
|
+
|
207
|
+
```
|
208
|
+
|
209
|
+
* Verify local override value
|
210
|
+
|
211
|
+
```ruby
|
212
|
+
|
213
|
+
# => object_instance_one.some_array_configuration.should == [ :yet_another_value ]
|
214
|
+
# => CascadingConfiguration::MockClass.some_array_configuration.should == [ :another_value ]
|
215
|
+
# => CascadingConfiguration::MockModule.some_array_configuration.should == [ :some_value ]
|
216
|
+
|
217
|
+
```
|
218
|
+
|
219
|
+
# First Inheriting Class #
|
220
|
+
|
221
|
+
6. Inheriting class.
|
222
|
+
|
223
|
+
Inheriting class should not get any settings from instance of superclass.
|
224
|
+
|
225
|
+
* Verify inherited value
|
226
|
+
|
227
|
+
```ruby
|
228
|
+
|
229
|
+
class CascadingConfiguration::MockClassSub1 < CascadingConfiguration::MockClass
|
230
|
+
# => some_array_configuration.should == [ :another_value ]
|
231
|
+
end
|
232
|
+
|
233
|
+
```
|
234
|
+
|
235
|
+
* Override inherited value
|
236
|
+
|
237
|
+
```ruby
|
238
|
+
|
239
|
+
class CascadingConfiguration::MockClassSub1 < CascadingConfiguration::MockClass
|
240
|
+
self.some_array_configuration = [ :a_value_not_yet_used ]
|
241
|
+
end
|
242
|
+
|
243
|
+
```
|
244
|
+
|
245
|
+
* Verify local override value
|
246
|
+
|
247
|
+
```ruby
|
248
|
+
|
249
|
+
class CascadingConfiguration::MockClassSub1 < CascadingConfiguration::MockClass
|
250
|
+
# => some_array_configuration.should == [ :a_value_not_yet_used ]
|
251
|
+
# => CascadingConfiguration::MockClass.some_array_configuration.should == [ :another_value ]
|
252
|
+
# => CascadingConfiguration::MockModule.some_array_configuration.should == [ :some_value ]
|
253
|
+
end
|
254
|
+
|
255
|
+
```
|
256
|
+
|
257
|
+
## Instance of First Inheriting Class ##
|
258
|
+
|
259
|
+
7. Instantiate first inheriting class.
|
260
|
+
|
261
|
+
```ruby
|
262
|
+
|
263
|
+
object_instance_two = CascadingConfiguration::MockClassSub1.new
|
264
|
+
|
265
|
+
```
|
266
|
+
|
267
|
+
* Verify inherited value
|
268
|
+
|
269
|
+
```ruby
|
270
|
+
|
271
|
+
# => object_instance_two.some_array_configuration.should == [ :a_value_not_yet_used ]
|
272
|
+
# => object_instance_one.some_array_configuration.should == [ :yet_another_value ]
|
273
|
+
# => CascadingConfiguration::MockClass.some_array_configuration.should == [ :another_value ]
|
274
|
+
# => CascadingConfiguration::MockModule.some_array_configuration.should == [ :some_value ]
|
275
|
+
|
276
|
+
```
|
277
|
+
|
278
|
+
## Second Inheriting Class ##
|
279
|
+
|
280
|
+
8. Second inheriting class.
|
281
|
+
|
282
|
+
* Verify inherited value
|
283
|
+
|
284
|
+
```ruby
|
285
|
+
|
286
|
+
class CascadingConfiguration::MockClassSub2 < CascadingConfiguration::MockClassSub1
|
287
|
+
# => some_array_configuration.should == [ :a_value_not_yet_used ]
|
288
|
+
end
|
289
|
+
|
290
|
+
```
|
291
|
+
|
292
|
+
* Override inherited value
|
293
|
+
|
294
|
+
```ruby
|
295
|
+
|
296
|
+
class CascadingConfiguration::MockClassSub2 < CascadingConfiguration::MockClassSub1
|
297
|
+
self.some_array_configuration = [ :another_value_not_yet_used ]
|
298
|
+
end
|
299
|
+
|
300
|
+
```
|
301
|
+
|
302
|
+
* Verify local override value
|
303
|
+
|
304
|
+
```ruby
|
305
|
+
|
306
|
+
class CascadingConfiguration::MockClassSub2 < CascadingConfiguration::MockClassSub1
|
307
|
+
# => some_array_configuration.should == [ :another_value_not_yet_used ]
|
308
|
+
end
|
309
|
+
|
310
|
+
```
|
311
|
+
|
312
|
+
## Instance of Second Inheriting Class ##
|
313
|
+
|
314
|
+
9. Instantiate Second Inheriting Class.
|
315
|
+
|
316
|
+
```ruby
|
317
|
+
|
318
|
+
object_instance_three = CascadingConfiguration::MockClassSub2.new
|
319
|
+
|
320
|
+
```
|
321
|
+
|
322
|
+
* Verify inherited value
|
323
|
+
|
324
|
+
```ruby
|
325
|
+
|
326
|
+
# => object_instance_three.some_array_configuration.should == [ :another_value_not_yet_used ]
|
327
|
+
|
328
|
+
```
|
329
|
+
|
330
|
+
* Override inherited value
|
331
|
+
|
332
|
+
```ruby
|
333
|
+
|
334
|
+
object_instance_three.some_array_configuration = [ :one_more_unused_value ]
|
335
|
+
|
336
|
+
```
|
337
|
+
|
338
|
+
* Verify local override value
|
339
|
+
|
340
|
+
```ruby
|
341
|
+
|
342
|
+
# => object_instance_three.some_array_configuration.should == [ :one_more_unused_value ]
|
343
|
+
|
344
|
+
```
|
345
|
+
|
346
|
+
# License #
|
347
|
+
|
348
|
+
(The MIT License)
|
349
|
+
|
350
|
+
Copyright (c) 2011 Asher
|
351
|
+
|
352
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
353
|
+
a copy of this software and associated documentation files (the
|
354
|
+
'Software'), to deal in the Software without restriction, including
|
355
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
356
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
357
|
+
permit persons to whom the Software is furnished to do so, subject to
|
358
|
+
the following conditions:
|
359
|
+
|
360
|
+
The above copyright notice and this permission notice shall be
|
361
|
+
included in all copies or substantial portions of the Software.
|
362
|
+
|
363
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
364
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
365
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
366
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
367
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
368
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
369
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,118 +1,34 @@
|
|
1
1
|
== Cascading Configuration
|
2
2
|
|
3
|
-
http://rubygems.org/gems/cascading-configuration
|
4
|
-
|
5
|
-
==
|
6
|
-
|
7
|
-
Adds methods for cascading
|
8
|
-
|
9
|
-
==
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
==
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
########################
|
34
|
-
# including module 1 #
|
35
|
-
########################
|
36
|
-
|
37
|
-
module CascadingConfiguration::MockModule2
|
38
|
-
# => some_array_configuration.should == [ :some_value ]
|
39
|
-
self.some_array_configuration = [ :module_value ]
|
40
|
-
# => some_array_configuration.should == [ :module_value ]
|
41
|
-
end
|
42
|
-
|
43
|
-
########################
|
44
|
-
# including module 2 #
|
45
|
-
########################
|
46
|
-
|
47
|
-
module CascadingConfiguration::MockModule3
|
48
|
-
# => some_array_configuration.should == [ :module_value ]
|
49
|
-
end
|
50
|
-
|
51
|
-
###############
|
52
|
-
# top class #
|
53
|
-
###############
|
54
|
-
|
55
|
-
class CascadingConfiguration::MockClass
|
56
|
-
# => some_array_configuration.should == [ :module_value ]
|
57
|
-
self.some_array_configuration = [ :another_value ]
|
58
|
-
# => some_array_configuration.should == [ :another_value ]
|
59
|
-
end
|
60
|
-
|
61
|
-
###########################
|
62
|
-
# instance of top class #
|
63
|
-
###########################
|
64
|
-
|
65
|
-
object_instance_one = CascadingConfiguration::MockClass.new
|
66
|
-
# => object_instance_one.some_array_configuration.should == [ :another_value ]
|
67
|
-
object_instance_one.some_array_configuration = [ :yet_another_value ]
|
68
|
-
# => object_instance_one.some_array_configuration.should == [ :yet_another_value ]
|
69
|
-
# => CascadingConfiguration::MockClass.some_array_configuration.should == [ :another_value ]
|
70
|
-
# => CascadingConfiguration::MockModule.some_array_configuration.should == [ :some_value ]
|
71
|
-
|
72
|
-
############################
|
73
|
-
# first inheriting class #
|
74
|
-
############################
|
75
|
-
|
76
|
-
class CascadingConfiguration::MockClassSub1 < CascadingConfiguration::MockClass
|
77
|
-
# => some_array_configuration.should == [ :another_value ]
|
78
|
-
self.some_array_configuration = [ :a_value_not_yet_used ]
|
79
|
-
# => some_array_configuration.should == [ :a_value_not_yet_used ]
|
80
|
-
# => CascadingConfiguration::MockClass.some_array_configuration.should == [ :another_value ]
|
81
|
-
# => CascadingConfiguration::MockModule.some_array_configuration.should == [ :some_value ]
|
82
|
-
end
|
83
|
-
|
84
|
-
########################################
|
85
|
-
# instance of first inheriting class #
|
86
|
-
########################################
|
87
|
-
|
88
|
-
object_instance_two = CascadingConfiguration::MockClassSub1.new
|
89
|
-
# => object_instance_two.some_array_configuration.should == [ :a_value_not_yet_used ]
|
90
|
-
# => object_instance_one.some_array_configuration.should == [ :yet_another_value ]
|
91
|
-
# => CascadingConfiguration::MockClass.some_array_configuration.should == [ :another_value ]
|
92
|
-
# => CascadingConfiguration::MockModule.some_array_configuration.should == [ :some_value ]
|
93
|
-
|
94
|
-
#############################
|
95
|
-
# second inheriting class #
|
96
|
-
#############################
|
97
|
-
|
98
|
-
class CascadingConfiguration::MockClassSub2 < CascadingConfiguration::MockClassSub1
|
99
|
-
# => some_array_configuration.should == [ :a_value_not_yet_used ]
|
100
|
-
self.some_array_configuration = [ :another_value_not_yet_used ]
|
101
|
-
# => some_array_configuration.should == [ :another_value_not_yet_used ]
|
102
|
-
end
|
103
|
-
|
104
|
-
#########################################
|
105
|
-
# instance of second inheriting class #
|
106
|
-
#########################################
|
107
|
-
|
108
|
-
object_instance_three = CascadingConfiguration::MockClassSub2.new
|
109
|
-
# => object_instance_three.some_array_configuration.should == [ :another_value_not_yet_used ]
|
110
|
-
object_instance_three.some_array_configuration = [ :one_more_unused_value ]
|
111
|
-
# => object_instance_three.some_array_configuration.should == [ :one_more_unused_value ]
|
112
|
-
|
113
|
-
#############################################################################
|
114
|
-
|
115
|
-
== LICENSE:
|
3
|
+
http://rubygems.org/gems/cascading-configuration
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
Adds methods for cascading configurations.
|
8
|
+
|
9
|
+
== Summary
|
10
|
+
|
11
|
+
Cascading configuration methods for single settings, arrays, hashes.
|
12
|
+
|
13
|
+
== :attr_configuration_array
|
14
|
+
|
15
|
+
:attr_configuration_array provides inheritable configuration that cascades downward.
|
16
|
+
|
17
|
+
Configuration inheritance can cascade through modules, classes, and instances.
|
18
|
+
|
19
|
+
:attr_configuration_array defines a single attribute accessor that composes the set of configuration values appropriate to the ancestor level being queried (merging downward from most distant ancestor to self). An internal cache is kept, and any configuration updates that occur to higher-level ancestors cascade immediately downward.
|
20
|
+
|
21
|
+
The array maintained by :attr_configuration_array is kept ordered and unique.
|
22
|
+
|
23
|
+
== Install
|
24
|
+
|
25
|
+
* sudo gem install cascading-configuration
|
26
|
+
|
27
|
+
== Usage
|
28
|
+
|
29
|
+
See supporting package README markdown files (README.md) for examples.
|
30
|
+
|
31
|
+
== License
|
116
32
|
|
117
33
|
(The MIT License)
|
118
34
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
|
2
|
+
module CascadingConfiguration::Array::Accessors
|
3
|
+
|
4
|
+
extend CascadingConfiguration::InternalModuleStub
|
5
|
+
|
6
|
+
###################
|
7
|
+
# self.extended #
|
8
|
+
###################
|
9
|
+
|
10
|
+
def self.extended( class_or_module )
|
11
|
+
class_or_module.instance_eval do
|
12
|
+
# accessor support in module to permit method overriding with super
|
13
|
+
unless const_defined?( :AccessorSupportModule )
|
14
|
+
accessor_support_module = Module.new { extend CascadingConfiguration::InternalModuleStub }
|
15
|
+
const_set( :AccessorSupportModule, accessor_support_module )
|
16
|
+
include class_or_module::AccessorSupportModule
|
17
|
+
extend class_or_module::AccessorSupportModule
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
###################################
|
23
|
+
# define_cascading_array_setter #
|
24
|
+
###################################
|
25
|
+
|
26
|
+
def define_cascading_array_setter( configuration_name )
|
27
|
+
configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
|
28
|
+
self::AccessorSupportModule.module_eval do
|
29
|
+
define_method( configuration_setter_name ) do |array|
|
30
|
+
composite_array = composite_array_for_cascading_configuration( configuration_name )
|
31
|
+
# we want the array to supplant existing config
|
32
|
+
# clear the array (excludes everything explicitly)
|
33
|
+
composite_array.clear
|
34
|
+
# push array elements (removes anything excluded from exclude)
|
35
|
+
composite_array.push( *array )
|
36
|
+
return composite_array
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
###################################
|
42
|
+
# define_cascading_array_getter #
|
43
|
+
###################################
|
44
|
+
|
45
|
+
def define_cascading_array_getter( configuration_name )
|
46
|
+
configuration_getter_name = configuration_name
|
47
|
+
self::AccessorSupportModule.module_eval do
|
48
|
+
define_method( configuration_getter_name ) do
|
49
|
+
return composite_array_for_cascading_configuration( configuration_name )
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
|
2
|
-
module CascadingConfiguration::
|
2
|
+
module CascadingConfiguration::Array::ClassInstance
|
3
|
+
|
4
|
+
extend CascadingConfiguration::InternalModuleStub
|
3
5
|
|
4
6
|
##############################
|
5
7
|
# attr_configuration_array #
|
@@ -8,9 +10,9 @@ module CascadingConfiguration::ConfigurationSettingsArray::ClassInstance
|
|
8
10
|
def attr_configuration_array( *property_names )
|
9
11
|
property_names.each do |this_property_name|
|
10
12
|
# define configuration setter
|
11
|
-
|
13
|
+
define_cascading_array_setter( this_property_name )
|
12
14
|
# define configuration getter
|
13
|
-
|
15
|
+
define_cascading_array_getter( this_property_name )
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
@@ -1,19 +1,22 @@
|
|
1
1
|
|
2
|
-
module CascadingConfiguration::
|
2
|
+
module CascadingConfiguration::Array::ModuleInstance
|
3
3
|
|
4
|
+
extend CascadingConfiguration::InternalModuleStub
|
5
|
+
|
4
6
|
##############
|
5
7
|
# included #
|
6
8
|
##############
|
7
9
|
|
8
10
|
def included( class_or_module )
|
9
|
-
|
11
|
+
super if method_defined?( :super )
|
12
|
+
module_self = self
|
10
13
|
class_or_module.instance_eval do
|
11
|
-
include CascadingConfiguration::
|
14
|
+
include CascadingConfiguration::Array
|
12
15
|
# when we extend a module (which has happened if we got here)
|
13
16
|
# then we need to make sure when the module we are extending is included
|
14
17
|
# * CascadingConfiguration is included
|
15
18
|
# * the module we extended is used to extend the class/module that included
|
16
|
-
extend
|
19
|
+
extend module_self
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
module CascadingConfiguration::Array
|
3
|
+
|
4
|
+
extend CascadingConfiguration::InternalModuleStub
|
5
|
+
|
6
|
+
###################
|
7
|
+
# self.included #
|
8
|
+
###################
|
9
|
+
|
10
|
+
def self.included( class_or_module )
|
11
|
+
module_self = self
|
12
|
+
class_or_module.instance_eval do
|
13
|
+
include CascadingConfiguration::Variable
|
14
|
+
extend module_self
|
15
|
+
extend CascadingConfiguration::Array::Accessors
|
16
|
+
extend CascadingConfiguration::Array::ClassInstance
|
17
|
+
include CascadingConfiguration::CompositingArray::Instance
|
18
|
+
# module support
|
19
|
+
unless is_a?( Class )
|
20
|
+
extend CascadingConfiguration::Array::ModuleInstance
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
#########################
|
26
|
+
# ancestors_to_Object #
|
27
|
+
#########################
|
28
|
+
|
29
|
+
def ancestors_to_Object
|
30
|
+
return ancestors_to_class_or_module_interpolating_module_branches( Object, CascadingConfiguration::Array::ModuleInstance )
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
|
2
|
-
module CascadingConfiguration::
|
2
|
+
module CascadingConfiguration::CompositingArray::Instance
|
3
|
+
|
4
|
+
extend CascadingConfiguration::InternalModuleStub
|
3
5
|
|
4
6
|
###################
|
5
7
|
# self.included #
|
@@ -26,7 +28,7 @@ module CascadingConfiguration::CascadingCompositeArray::Instance
|
|
26
28
|
if instance_variable_defined?( composite_array_variable )
|
27
29
|
composite_array = instance_variable_get( composite_array_variable )
|
28
30
|
else
|
29
|
-
composite_array = ::CascadingConfiguration::
|
31
|
+
composite_array = ::CascadingConfiguration::CompositingArray.new( cascading_name, self )
|
30
32
|
instance_variable_set( composite_array_variable, composite_array )
|
31
33
|
end
|
32
34
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
module CascadingConfiguration::
|
2
|
+
module CascadingConfiguration::CompositingArray::Instance
|
3
3
|
|
4
4
|
###########################################################################################################
|
5
5
|
private ###############################################################################################
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
class CascadingConfiguration::
|
2
|
+
class CascadingConfiguration::CompositingArray < Array
|
3
3
|
|
4
4
|
attr_accessor :working_instance, :local_cascading_array
|
5
5
|
|
@@ -17,9 +17,9 @@ class CascadingConfiguration::CascadingCompositeArray < Array
|
|
17
17
|
@parent_composite_array.register_child_composite_array( self )
|
18
18
|
end
|
19
19
|
# get local cascading array (not included in parent composite)
|
20
|
-
@local_cascading_array = ::CascadingConfiguration::
|
20
|
+
@local_cascading_array = ::CascadingConfiguration::LocalConfigurationArray.new
|
21
21
|
# we may later have our own child composites
|
22
|
-
@child_composite_arrays = Array.new
|
22
|
+
@child_composite_arrays = ::Array.new
|
23
23
|
# initialize self status for parent and local
|
24
24
|
update_self_as_cascading_composite
|
25
25
|
end
|