cascading-configuration-array 1.1.6 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +122 -202
- data/README.rdoc +12 -8
- data/lib/cascading-configuration-array.rb +2 -2
- data/lib/cascading-configuration-array/CascadingConfiguration/Array.rb +2 -2
- data/lib/cascading-configuration-array/CascadingConfiguration/Array/{ConfigurationAccessors.rb → AccessorDefinitionMethods.rb} +7 -7
- data/lib/cascading-configuration-array/CascadingConfiguration/Array/Interface.rb +6 -4
- data/spec/CascadingConfiguration/Array/{ConfigurationAccessors_spec.rb → AccessorDefinitionMethods_spec.rb} +2 -2
- data/spec/CascadingConfiguration/Array_spec.rb +294 -25
- metadata +5 -5
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Cascading Configuration #
|
1
|
+
# Cascading Configuration Array #
|
2
2
|
|
3
3
|
http://rubygems.org/gems/cascading-configuration-array
|
4
4
|
|
@@ -8,340 +8,260 @@ Adds methods for cascading configuration arrays. Support package for cascading-c
|
|
8
8
|
|
9
9
|
# Summary #
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
:attr_configuration_array provides inheritable configuration that cascades downward.
|
11
|
+
Cascading configuration methods for arrays, which returns the appropriate lowest accumulated value. Configuration inheritance can cascade through modules, classes, and to instances.
|
14
12
|
|
15
|
-
|
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.
|
13
|
+
This means that we can create configuration modules, optionally setting configuration defaults, and include those configuration modules in other modules or classes.
|
20
14
|
|
21
15
|
# Install #
|
22
16
|
|
23
|
-
* sudo gem install cascading-configuration
|
17
|
+
* sudo gem install cascading-configuration
|
24
18
|
|
25
19
|
# Usage #
|
26
20
|
|
27
|
-
|
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.
|
21
|
+
Including the module will enable support for singleton and for instances.
|
34
22
|
|
35
23
|
```ruby
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
24
|
+
module AnyModuleOrClass
|
25
|
+
include CascadingConfiguration
|
26
|
+
end
|
61
27
|
```
|
62
28
|
|
63
|
-
|
29
|
+
Extending the module will enable support for singleton only.
|
64
30
|
|
65
31
|
```ruby
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
# => some_array_configuration.should == [ :some_value ]
|
70
|
-
|
71
|
-
end
|
72
|
-
|
32
|
+
module AnyModuleOrClass
|
33
|
+
extend CascadingConfiguration
|
34
|
+
end
|
73
35
|
```
|
74
36
|
|
75
|
-
|
37
|
+
Including or extending CascadingConfiguration includes or extends:
|
76
38
|
|
77
|
-
|
39
|
+
* CascadingConfiguration::Variable
|
78
40
|
|
79
|
-
|
41
|
+
## :attr_configuration_array ##
|
80
42
|
|
81
|
-
|
43
|
+
:attr_configuration_array provides inheritable array configurations that cascade downward. A composite sorted and unique array will be returned (merging downward from most distant ancestor to self).
|
82
44
|
|
83
|
-
|
84
|
-
include CascadingConfiguration::MockModule
|
85
|
-
end
|
45
|
+
An internal cache is kept, and any configuration updates that occur to higher-level ancestors cascade immediately downward.
|
86
46
|
|
87
|
-
|
47
|
+
The array maintained by :attr_configuration_array is kept ordered and unique.
|
88
48
|
|
89
|
-
|
49
|
+
Define initial configuration in a module or class:
|
90
50
|
|
91
51
|
```ruby
|
52
|
+
module SomeModule
|
92
53
|
|
93
|
-
|
94
|
-
# => some_array_configuration.should == [ :some_value ]
|
95
|
-
end
|
54
|
+
include CascadingConfiguration::Array
|
96
55
|
|
97
|
-
|
56
|
+
attr_array_configuration :some_array_setting
|
98
57
|
|
99
|
-
|
58
|
+
some_array_setting # => nil
|
100
59
|
|
101
|
-
|
60
|
+
some_array_setting.push( :some_value )
|
102
61
|
|
103
|
-
|
104
|
-
self.some_array_configuration = [ :module_value ]
|
105
|
-
end
|
62
|
+
some_array_setting # => [ :some_value ]
|
106
63
|
|
64
|
+
end
|
107
65
|
```
|
108
66
|
|
109
|
-
|
67
|
+
Include initial module in a module or class:
|
110
68
|
|
111
69
|
```ruby
|
70
|
+
class SomeClass
|
112
71
|
|
113
|
-
|
114
|
-
# => some_array_configuration.should == [ :module_value ]
|
115
|
-
end
|
72
|
+
include SomeModule
|
116
73
|
|
117
|
-
|
74
|
+
some_array_setting # => [ :some_value ]
|
118
75
|
|
119
|
-
|
76
|
+
self.some_array_setting = [ :some_other_value ]
|
120
77
|
|
121
|
-
|
78
|
+
some_array_setting # => [ :some_other_value ]
|
122
79
|
|
123
|
-
|
80
|
+
some_array_setting.push( :another_value ) # => [ :another_value, :some_other_value ]
|
124
81
|
|
125
|
-
|
126
|
-
include CascadingConfiguration::MockModule2
|
127
|
-
end
|
82
|
+
SomeModule.some_array_setting # => [ :some_value ]
|
128
83
|
|
84
|
+
end
|
129
85
|
```
|
130
86
|
|
131
|
-
|
87
|
+
And it cascades to instances:
|
132
88
|
|
133
89
|
```ruby
|
90
|
+
instance = SomeClass.new
|
134
91
|
|
135
|
-
|
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
|
92
|
+
instance.some_array_setting.should == [ :another_value, :some_other_value ]
|
146
93
|
|
147
|
-
|
148
|
-
include CascadingConfiguration::MockModule3
|
149
|
-
end
|
94
|
+
instance.some_array_setting.delete( :some_other_value )
|
150
95
|
|
96
|
+
instance.some_array_setting.should == [ :another_value ]
|
151
97
|
```
|
152
98
|
|
153
|
-
|
99
|
+
### :attr_module_configuration_array, :attr_class_configuration_array ###
|
100
|
+
|
101
|
+
:attr_class_configuration_array works like :attr_configuration_array but does not cascade to instances.
|
154
102
|
|
155
103
|
```ruby
|
104
|
+
module SomeModule
|
156
105
|
|
157
|
-
|
158
|
-
# => some_array_configuration.should == [ :module_value ]
|
159
|
-
end
|
106
|
+
include CascadingConfiguration::Array
|
160
107
|
|
161
|
-
|
108
|
+
attr_array_configuration :some_array_setting
|
162
109
|
|
163
|
-
|
110
|
+
some_array_setting # => nil
|
164
111
|
|
165
|
-
|
112
|
+
some_array_setting.push( :some_value )
|
166
113
|
|
167
|
-
|
168
|
-
self.some_array_configuration = [ :another_value ]
|
169
|
-
end
|
114
|
+
some_array_setting # => [ :some_value ]
|
170
115
|
|
116
|
+
end
|
171
117
|
```
|
172
118
|
|
173
|
-
|
119
|
+
Include initial module in a module or class:
|
174
120
|
|
175
121
|
```ruby
|
122
|
+
class SomeClass
|
176
123
|
|
177
|
-
|
178
|
-
# => some_array_configuration.should == [ :another_value ]
|
179
|
-
end
|
124
|
+
include SomeModule
|
180
125
|
|
181
|
-
|
126
|
+
some_array_setting # => [ :some_value ]
|
182
127
|
|
183
|
-
|
128
|
+
self.some_array_setting = [ :some_other_value ]
|
184
129
|
|
185
|
-
|
130
|
+
some_array_setting # => [ :some_other_value ]
|
186
131
|
|
187
|
-
|
132
|
+
some_array_setting.push( :another_value ) # => [ :another_value, :some_other_value ]
|
188
133
|
|
189
|
-
|
134
|
+
SomeModule.some_array_setting # => [ :some_value ]
|
190
135
|
|
136
|
+
end
|
191
137
|
```
|
192
138
|
|
193
|
-
|
139
|
+
And it does not cascade to instances:
|
194
140
|
|
195
141
|
```ruby
|
142
|
+
instance = SomeClass.new
|
196
143
|
|
197
|
-
|
198
|
-
|
144
|
+
instance.respond_to?( :some_array_setting ).should == false
|
199
145
|
```
|
200
146
|
|
201
|
-
|
147
|
+
### :attr_local_configuration_array ###
|
202
148
|
|
203
|
-
|
204
|
-
|
205
|
-
object_instance_one.some_array_configuration = [ :yet_another_value ]
|
206
|
-
|
207
|
-
```
|
208
|
-
|
209
|
-
* Verify local override value
|
149
|
+
:attr_local_configuration_array works like :attr_configuration_array but does not cascade. This is primarily useful for creating local configurations maintained in parallel with cascading configurations (for instance, with the same variable prefixes), for overriding the local configuration method, and for hiding the configuration variable (coming soon).
|
210
150
|
|
211
151
|
```ruby
|
152
|
+
module SomeModule
|
212
153
|
|
213
|
-
|
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.
|
154
|
+
include CascadingConfiguration::Array
|
222
155
|
|
223
|
-
|
156
|
+
attr_array_configuration :some_array_setting
|
224
157
|
|
225
|
-
|
158
|
+
some_array_setting # => nil
|
226
159
|
|
227
|
-
|
160
|
+
some_array_setting.push( :some_value )
|
228
161
|
|
229
|
-
|
230
|
-
# => some_array_configuration.should == [ :another_value ]
|
231
|
-
end
|
162
|
+
some_array_setting # => [ :some_value ]
|
232
163
|
|
164
|
+
end
|
233
165
|
```
|
234
166
|
|
235
|
-
|
167
|
+
Include initial module in a module or class:
|
236
168
|
|
237
169
|
```ruby
|
170
|
+
class SomeClass
|
238
171
|
|
239
|
-
|
240
|
-
self.some_array_configuration = [ :a_value_not_yet_used ]
|
241
|
-
end
|
172
|
+
include SomeModule
|
242
173
|
|
243
|
-
|
174
|
+
respond_to?( :some_array_setting ).should == false
|
244
175
|
|
245
|
-
|
176
|
+
end
|
177
|
+
```
|
246
178
|
|
247
|
-
|
179
|
+
## Additional Functionality ##
|
248
180
|
|
249
|
-
|
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
|
181
|
+
Cascading-configuration also provides several other convenience functions.
|
254
182
|
|
255
|
-
|
183
|
+
### Variable Name Prefixing ###
|
256
184
|
|
257
|
-
|
185
|
+
Configuration prefix can be set so that variables use property name with the configuration prefix prepended.
|
258
186
|
|
259
|
-
|
187
|
+
This can be done in order defined (current configuration prefix is stored for configuration), or it can be specified on a per-property basis.
|
260
188
|
|
261
189
|
```ruby
|
190
|
+
module SomeModule
|
262
191
|
|
263
|
-
|
192
|
+
include CascadingConfiguration
|
264
193
|
|
265
|
-
|
194
|
+
attr_configuration :some_setting
|
266
195
|
|
267
|
-
|
196
|
+
self.some_setting = :a_value
|
268
197
|
|
269
|
-
|
198
|
+
instance_variables.include?( :@some_setting ) # => true
|
270
199
|
|
271
|
-
#
|
272
|
-
|
273
|
-
# => CascadingConfiguration::MockClass.some_array_configuration.should == [ :another_value ]
|
274
|
-
# => CascadingConfiguration::MockModule.some_array_configuration.should == [ :some_value ]
|
200
|
+
# we can declare a prefix for specific properties
|
201
|
+
attr_configuration_prefix '__configuration_prefix__', :some_other_setting
|
275
202
|
|
276
|
-
|
203
|
+
attr_configuration :some_other_setting, :yet_another_setting
|
277
204
|
|
278
|
-
|
205
|
+
self.some_setting = :some_value
|
206
|
+
self.yet_another_setting = :another_value
|
279
207
|
|
280
|
-
|
208
|
+
instance_variables.include?( :@some_other_setting ) # => false
|
209
|
+
instance_variables.include?( :@__configuration_prefix__some_other_setting ) # => true
|
210
|
+
instance_variables.include?( :@yet_another_setting ) # => true
|
281
211
|
|
282
|
-
|
212
|
+
# or we can declare a prefix for all properties defined after prefix is declared
|
213
|
+
attr_configuration_prefix '__another_configuration_prefix__'
|
283
214
|
|
284
|
-
|
215
|
+
attr_configuration :still_another_prefix
|
285
216
|
|
286
|
-
|
287
|
-
|
288
|
-
end
|
217
|
+
instance_variables.include?( :@still_another_prefix ) # => false
|
218
|
+
instance_variables.include?( :@__another_configuration_prefix__still_another_prefix ) # => true
|
289
219
|
|
220
|
+
end
|
290
221
|
```
|
291
222
|
|
292
|
-
|
223
|
+
### Method Redefinition ###
|
293
224
|
|
294
|
-
|
295
|
-
|
296
|
-
class CascadingConfiguration::MockClassSub2 < CascadingConfiguration::MockClassSub1
|
297
|
-
self.some_array_configuration = [ :another_value_not_yet_used ]
|
298
|
-
end
|
225
|
+
Any declared configuration is defined in order to support locally redefining the method and accessing the original by calling super.
|
299
226
|
|
300
|
-
```
|
227
|
+
```ruby
|
228
|
+
module SomeModule
|
301
229
|
|
302
|
-
|
230
|
+
include CascadingConfiguration
|
303
231
|
|
304
|
-
|
232
|
+
attr_configuration :some_array_setting
|
305
233
|
|
306
|
-
|
307
|
-
|
234
|
+
def some_array_setting=( value )
|
235
|
+
puts 'Replacing configuration array!'
|
236
|
+
super
|
308
237
|
end
|
309
238
|
|
239
|
+
end
|
310
240
|
```
|
311
241
|
|
312
|
-
|
242
|
+
### Hidden Configuration ###
|
313
243
|
|
314
|
-
|
244
|
+
#### :attr_hide ####
|
315
245
|
|
316
|
-
|
317
|
-
|
318
|
-
object_instance_three = CascadingConfiguration::MockClassSub2.new
|
319
|
-
|
320
|
-
```
|
321
|
-
|
322
|
-
* Verify inherited value
|
246
|
+
Coming soon.
|
323
247
|
|
324
248
|
```ruby
|
249
|
+
module SomeModule
|
325
250
|
|
326
|
-
|
251
|
+
include CascadingConfiguration
|
327
252
|
|
328
|
-
|
253
|
+
attr_configuration :some_array_setting
|
329
254
|
|
330
|
-
|
255
|
+
instance_variables.include?( :@some_array_setting ) # => true
|
331
256
|
|
332
|
-
|
257
|
+
attr_hide :some_array_setting
|
333
258
|
|
334
|
-
|
259
|
+
instance_variables.include?( :@some_array_setting ) # => false
|
335
260
|
|
261
|
+
end
|
336
262
|
```
|
337
263
|
|
338
|
-
|
339
|
-
|
340
|
-
```ruby
|
341
|
-
|
342
|
-
# => object_instance_three.some_array_configuration.should == [ :one_more_unused_value ]
|
343
|
-
|
344
|
-
```
|
264
|
+
Causes configuration variable to be stored in external context so that it is not included in instance variables.
|
345
265
|
|
346
266
|
# License #
|
347
267
|
|
data/README.rdoc
CHANGED
@@ -1,32 +1,36 @@
|
|
1
1
|
== Cascading Configuration
|
2
2
|
|
3
|
-
http://rubygems.org/gems/cascading-configuration
|
3
|
+
http://rubygems.org/gems/cascading-configuration-array
|
4
4
|
|
5
5
|
== Description
|
6
6
|
|
7
|
-
Adds methods for cascading
|
7
|
+
Adds methods for cascading configuration arrays. Support package for cascading-configuration.
|
8
8
|
|
9
9
|
== Summary
|
10
10
|
|
11
|
-
Cascading configuration methods for
|
11
|
+
Cascading configuration methods for arrays, which returns the appropriate lowest accumulated value. Configuration inheritance can cascade through modules, classes, and to instances.
|
12
12
|
|
13
|
-
|
13
|
+
This means that we can create configuration modules, optionally setting configuration defaults, and include those configuration modules in other modules or classes.
|
14
14
|
|
15
|
-
:attr_configuration_array
|
15
|
+
== :attr_configuration_array
|
16
16
|
|
17
|
-
|
17
|
+
:attr_configuration_array provides inheritable array configurations that cascade downward. A composite sorted and unique array will be returned (merging downward from most distant ancestor to self).
|
18
18
|
|
19
|
-
|
19
|
+
An internal cache is kept, and any configuration updates that occur to higher-level ancestors cascade immediately downward.
|
20
20
|
|
21
21
|
The array maintained by :attr_configuration_array is kept ordered and unique.
|
22
22
|
|
23
|
+
:attr_class_configuration_array works like :attr_configuration_array but does not cascade to instances.
|
24
|
+
|
25
|
+
:attr_local_configuration_array works like :attr_configuration_array but does not cascade. This is primarily useful for creating local configurations maintained in parallel with cascading configurations (for instance, with the same variable prefixes), for overriding the local configuration method, and for hiding the configuration variable (coming soon).
|
26
|
+
|
23
27
|
== Install
|
24
28
|
|
25
29
|
* sudo gem install cascading-configuration
|
26
30
|
|
27
31
|
== Usage
|
28
32
|
|
29
|
-
See
|
33
|
+
See README.md
|
30
34
|
|
31
35
|
== License
|
32
36
|
|
@@ -13,7 +13,7 @@ module CascadingConfiguration
|
|
13
13
|
class LocalConfigurationArray < Array
|
14
14
|
end
|
15
15
|
module Array
|
16
|
-
module
|
16
|
+
module AccessorDefinitionMethods
|
17
17
|
end
|
18
18
|
module Interface
|
19
19
|
end
|
@@ -30,6 +30,6 @@ require_relative 'cascading-configuration-array/CascadingConfiguration/Compositi
|
|
30
30
|
require_relative 'cascading-configuration-array/CascadingConfiguration/LocalConfigurationArray.rb'
|
31
31
|
require_relative 'cascading-configuration-array/CascadingConfiguration/_private_/LocalConfigurationArray.rb'
|
32
32
|
require_relative 'cascading-configuration-array/CascadingConfiguration/Array.rb'
|
33
|
-
require_relative 'cascading-configuration-array/CascadingConfiguration/Array/
|
33
|
+
require_relative 'cascading-configuration-array/CascadingConfiguration/Array/AccessorDefinitionMethods.rb'
|
34
34
|
require_relative 'cascading-configuration-array/CascadingConfiguration/Array/Interface.rb'
|
35
35
|
require_relative 'cascading-configuration-array/CascadingConfiguration/Array/ModuleInclusionExtensionSupport.rb'
|
@@ -34,7 +34,7 @@ module CascadingConfiguration::Array
|
|
34
34
|
class_or_module.instance_eval do
|
35
35
|
extend module_self
|
36
36
|
extend module_self::Interface
|
37
|
-
extend module_self::
|
37
|
+
extend module_self::AccessorDefinitionMethods
|
38
38
|
extend CascadingConfiguration::Array::ModuleInclusionExtensionSupport unless is_a?( Class )
|
39
39
|
end
|
40
40
|
end
|
@@ -47,7 +47,7 @@ module CascadingConfiguration::Array
|
|
47
47
|
module_self = self
|
48
48
|
class_or_module.instance_eval do
|
49
49
|
extend module_self::Interface
|
50
|
-
extend module_self::
|
50
|
+
extend module_self::AccessorDefinitionMethods
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
module CascadingConfiguration::Array::
|
2
|
+
module CascadingConfiguration::Array::AccessorDefinitionMethods
|
3
3
|
|
4
4
|
extend CascadingConfiguration::InternalModuleStub
|
5
5
|
|
@@ -10,8 +10,8 @@ module CascadingConfiguration::Array::ConfigurationAccessors
|
|
10
10
|
def define_cascading_array_setter( configuration_name )
|
11
11
|
configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
|
12
12
|
self_instance = self
|
13
|
-
[ accessor_instance_support, accessor_module_support ].compact.each do |
|
14
|
-
|
13
|
+
[ accessor_instance_support, accessor_module_support ].compact.each do |accessor_module_support|
|
14
|
+
accessor_module_support.module_eval do
|
15
15
|
define_method( configuration_setter_name ) do |array|
|
16
16
|
composite_array = composite_array_for_cascading_configuration( configuration_name )
|
17
17
|
# we want the array to supplant existing config
|
@@ -31,8 +31,8 @@ module CascadingConfiguration::Array::ConfigurationAccessors
|
|
31
31
|
|
32
32
|
def define_cascading_array_getter( configuration_name )
|
33
33
|
configuration_getter_name = configuration_name
|
34
|
-
[ accessor_instance_support, accessor_module_support ].compact.each do |
|
35
|
-
|
34
|
+
[ accessor_instance_support, accessor_module_support ].compact.each do |accessor_module_support|
|
35
|
+
accessor_module_support.module_eval do
|
36
36
|
define_method( configuration_getter_name ) do
|
37
37
|
return composite_array_for_cascading_configuration( configuration_name )
|
38
38
|
end
|
@@ -78,7 +78,7 @@ module CascadingConfiguration::Array::ConfigurationAccessors
|
|
78
78
|
|
79
79
|
def define_local_configuration_array_setter( configuration_name )
|
80
80
|
configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
|
81
|
-
|
81
|
+
accessor_local_instance_support.module_eval do
|
82
82
|
define_method( configuration_setter_name ) do |array|
|
83
83
|
composite_array = composite_array_for_cascading_configuration( configuration_name )
|
84
84
|
# we want the array to supplant existing config
|
@@ -97,7 +97,7 @@ module CascadingConfiguration::Array::ConfigurationAccessors
|
|
97
97
|
|
98
98
|
def define_local_configuration_array_getter( configuration_name )
|
99
99
|
configuration_getter_name = configuration_name
|
100
|
-
|
100
|
+
accessor_local_instance_support.module_eval do
|
101
101
|
define_method( configuration_getter_name ) do
|
102
102
|
return composite_array_for_cascading_configuration( configuration_name )
|
103
103
|
end
|
@@ -18,13 +18,13 @@ module CascadingConfiguration::Array::Interface
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
#
|
23
|
-
|
21
|
+
#####################################
|
22
|
+
# attr_module_configuration_array #
|
23
|
+
#####################################
|
24
24
|
|
25
25
|
# defines configuration in class or module
|
26
26
|
# configuration cascades downward to last class or module
|
27
|
-
def
|
27
|
+
def attr_module_configuration_array( *property_names )
|
28
28
|
property_names.each do |this_property_name|
|
29
29
|
# define configuration setter
|
30
30
|
define_class_configuration_array_setter( this_property_name )
|
@@ -32,6 +32,7 @@ module CascadingConfiguration::Array::Interface
|
|
32
32
|
define_class_configuration_array_getter( this_property_name )
|
33
33
|
end
|
34
34
|
end
|
35
|
+
alias_method :attr_class_configuration_array, :attr_module_configuration_array
|
35
36
|
|
36
37
|
####################################
|
37
38
|
# attr_local_configuration_array #
|
@@ -40,6 +41,7 @@ module CascadingConfiguration::Array::Interface
|
|
40
41
|
# defines configuration in present class or module context
|
41
42
|
# configuration does not cascade
|
42
43
|
def attr_local_configuration_array( *property_names )
|
44
|
+
CascadingConfiguration::Variable.define_accessor_local_instance_support( self )
|
43
45
|
property_names.each do |this_property_name|
|
44
46
|
# define configuration setter
|
45
47
|
define_local_configuration_array_setter( this_property_name )
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
require_relative '../../../lib/cascading-configuration-array.rb'
|
3
3
|
|
4
|
-
describe CascadingConfiguration::Array::
|
4
|
+
describe CascadingConfiguration::Array::AccessorDefinitionMethods do
|
5
5
|
|
6
6
|
###################################
|
7
7
|
# define_cascading_array_setter #
|
@@ -11,7 +11,7 @@ describe CascadingConfiguration::Array::ConfigurationAccessors do
|
|
11
11
|
it 'can define a method to get and modify the configuration array' do
|
12
12
|
class CascadingConfiguration::Array::Mock
|
13
13
|
include CascadingConfiguration::Variable
|
14
|
-
extend CascadingConfiguration::Array::
|
14
|
+
extend CascadingConfiguration::Array::AccessorDefinitionMethods
|
15
15
|
include CascadingConfiguration::Array::ObjectInstance
|
16
16
|
extend CascadingConfiguration::Array::Interface
|
17
17
|
end
|
@@ -21,7 +21,7 @@ describe CascadingConfiguration::Array do
|
|
21
21
|
# => instances of including classes get configurations
|
22
22
|
# => extending modules and classes get attr_configuration and configurations
|
23
23
|
# => instances of extending classes get nothing
|
24
|
-
module CascadingConfiguration::Array::
|
24
|
+
module CascadingConfiguration::Array::ConfigurationMockModuleExtended
|
25
25
|
extend CascadingConfiguration::Array
|
26
26
|
# => singleton gets attr_configuration and configurations
|
27
27
|
respond_to?( :attr_configuration_array ).should == true
|
@@ -33,31 +33,31 @@ describe CascadingConfiguration::Array do
|
|
33
33
|
instance_methods.include?( :configuration_setting ).should == false
|
34
34
|
# => including modules and classes get nothing
|
35
35
|
module SubmoduleIncluding
|
36
|
-
include CascadingConfiguration::Array::
|
36
|
+
include CascadingConfiguration::Array::ConfigurationMockModuleExtended
|
37
37
|
instance_methods.include?( :configuration_setting ).should == false
|
38
38
|
respond_to?( :configuration_setting ).should == false
|
39
39
|
end
|
40
40
|
# => extending modules and classes get nothing
|
41
41
|
module SubmoduleExtending
|
42
|
-
extend CascadingConfiguration::Array::
|
42
|
+
extend CascadingConfiguration::Array::ConfigurationMockModuleExtended
|
43
43
|
instance_methods.include?( :configuration_setting ).should == false
|
44
44
|
respond_to?( :configuration_setting ).should == false
|
45
45
|
end
|
46
46
|
# => instances of including and extending classes get nothing
|
47
47
|
class ClassIncluding
|
48
|
-
include CascadingConfiguration::Array::
|
48
|
+
include CascadingConfiguration::Array::ConfigurationMockModuleExtended
|
49
49
|
instance_methods.include?( :configuration_setting ).should == false
|
50
50
|
respond_to?( :configuration_setting ).should == false
|
51
51
|
end
|
52
52
|
class ClassExtending
|
53
|
-
extend CascadingConfiguration::Array::
|
53
|
+
extend CascadingConfiguration::Array::ConfigurationMockModuleExtended
|
54
54
|
instance_methods.include?( :configuration_setting ).should == false
|
55
55
|
respond_to?( :configuration_setting ).should == false
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
# * module included with setting
|
60
|
-
module CascadingConfiguration::Array::
|
60
|
+
module CascadingConfiguration::Array::ConfigurationMockModuleIncluded
|
61
61
|
include CascadingConfiguration::Array
|
62
62
|
# => singleton gets attr_configuration and configurations
|
63
63
|
respond_to?( :attr_configuration_array ).should == true
|
@@ -69,7 +69,7 @@ describe CascadingConfiguration::Array do
|
|
69
69
|
instance_methods.include?( :configuration_setting ).should == true
|
70
70
|
# => including modules and classes get attr_configuration and configurations
|
71
71
|
module SubmoduleIncluding
|
72
|
-
include CascadingConfiguration::Array::
|
72
|
+
include CascadingConfiguration::Array::ConfigurationMockModuleIncluded
|
73
73
|
instance_methods.include?( :configuration_setting ).should == true
|
74
74
|
respond_to?( :configuration_setting ).should == true
|
75
75
|
configuration_setting.should == [ :a_configuration ]
|
@@ -78,7 +78,7 @@ describe CascadingConfiguration::Array do
|
|
78
78
|
end
|
79
79
|
# => extending modules and classes get attr_configuration and configurations
|
80
80
|
module SubmoduleExtending
|
81
|
-
extend CascadingConfiguration::Array::
|
81
|
+
extend CascadingConfiguration::Array::ConfigurationMockModuleIncluded
|
82
82
|
# if we're extended then we want to use the eigenclass ancestor chain
|
83
83
|
# - the first ancestor will be the extending module
|
84
84
|
# - the rest of the ancestors will be the extending module's include chain
|
@@ -90,7 +90,7 @@ describe CascadingConfiguration::Array do
|
|
90
90
|
end
|
91
91
|
# => instances of including classes get configurations
|
92
92
|
class ClassIncluding
|
93
|
-
include CascadingConfiguration::Array::
|
93
|
+
include CascadingConfiguration::Array::ConfigurationMockModuleIncluded
|
94
94
|
instance_methods.include?( :configuration_setting ).should == true
|
95
95
|
respond_to?( :configuration_setting ).should == true
|
96
96
|
configuration_setting.should == [ :a_configuration ]
|
@@ -105,7 +105,7 @@ describe CascadingConfiguration::Array do
|
|
105
105
|
setting_class_including_instance.configuration_setting.should == [ :our_setting_value ]
|
106
106
|
# => instances of extending classes get nothing
|
107
107
|
class ClassExtending
|
108
|
-
extend CascadingConfiguration::Array::
|
108
|
+
extend CascadingConfiguration::Array::ConfigurationMockModuleIncluded
|
109
109
|
respond_to?( :configuration_setting ).should == true
|
110
110
|
configuration_setting.should == [ :a_configuration ]
|
111
111
|
configuration_setting.push( :some_other_configuration )
|
@@ -115,50 +115,319 @@ describe CascadingConfiguration::Array do
|
|
115
115
|
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
116
116
|
end
|
117
117
|
|
118
|
-
class CascadingConfiguration::Array::
|
119
|
-
include CascadingConfiguration::Array::
|
118
|
+
class CascadingConfiguration::Array::ConfigurationMockClass
|
119
|
+
include CascadingConfiguration::Array::ConfigurationMockModuleIncluded::SubmoduleIncluding
|
120
120
|
configuration_setting.should == [ :a_configuration, :another_configuration ]
|
121
121
|
configuration_setting.push( :some_other_configuration )
|
122
122
|
configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
123
123
|
end
|
124
|
-
object_instance_one = CascadingConfiguration::Array::
|
124
|
+
object_instance_one = CascadingConfiguration::Array::ConfigurationMockClass.new
|
125
125
|
object_instance_one.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
126
126
|
object_instance_one.configuration_setting.delete( :a_configuration )
|
127
127
|
object_instance_one.configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
128
|
-
class CascadingConfiguration::Array::
|
128
|
+
class CascadingConfiguration::Array::ConfigurationMockClassSub1 < CascadingConfiguration::Array::ConfigurationMockClass
|
129
129
|
configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
130
130
|
configuration_setting.delete( :a_configuration )
|
131
131
|
configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
132
132
|
end
|
133
|
-
object_instance_two = CascadingConfiguration::Array::
|
133
|
+
object_instance_two = CascadingConfiguration::Array::ConfigurationMockClassSub1.new
|
134
134
|
object_instance_two.configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
135
135
|
object_instance_two.configuration_setting.delete( :another_configuration )
|
136
136
|
object_instance_two.configuration_setting.should == [ :some_other_configuration ]
|
137
|
-
class CascadingConfiguration::Array::
|
137
|
+
class CascadingConfiguration::Array::ConfigurationMockClassSub2 < CascadingConfiguration::Array::ConfigurationMockClassSub1
|
138
138
|
configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
139
139
|
configuration_setting.push( :yet_another_configuration )
|
140
140
|
configuration_setting.should == [ :another_configuration, :some_other_configuration, :yet_another_configuration ]
|
141
141
|
end
|
142
142
|
|
143
143
|
# change ancestor setting
|
144
|
-
CascadingConfiguration::Array::
|
145
|
-
CascadingConfiguration::Array::
|
146
|
-
CascadingConfiguration::Array::
|
144
|
+
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
145
|
+
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.push( :a_yet_unused_configuration )
|
146
|
+
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
|
147
147
|
object_instance_one.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
|
148
|
-
CascadingConfiguration::Array::
|
148
|
+
CascadingConfiguration::Array::ConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
|
149
149
|
object_instance_two.configuration_setting.should == [ :a_yet_unused_configuration, :some_other_configuration ]
|
150
150
|
|
151
151
|
# freeze ancestor setting
|
152
152
|
object_instance_one.configuration_setting.freeze!
|
153
153
|
object_instance_one.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
|
154
|
-
CascadingConfiguration::Array::
|
155
|
-
CascadingConfiguration::Array::
|
156
|
-
CascadingConfiguration::Array::
|
157
|
-
CascadingConfiguration::Array::
|
154
|
+
CascadingConfiguration::Array::ConfigurationMockClassSub1.configuration_setting.freeze!
|
155
|
+
CascadingConfiguration::Array::ConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
|
156
|
+
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.push( :non_cascading_configuration )
|
157
|
+
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :a_yet_unused_configuration, :another_configuration, :non_cascading_configuration, :some_other_configuration ]
|
158
158
|
object_instance_one.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
|
159
|
-
CascadingConfiguration::Array::
|
159
|
+
CascadingConfiguration::Array::ConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
|
160
160
|
object_instance_two.configuration_setting.should == [ :a_yet_unused_configuration, :some_other_configuration ]
|
161
161
|
|
162
162
|
end
|
163
|
+
|
164
|
+
#####################################
|
165
|
+
# attr_module_configuration_array #
|
166
|
+
# attr_class_configuration_array #
|
167
|
+
#####################################
|
168
|
+
|
169
|
+
it 'can define a class configuration array, which will not cascade to instances' do
|
170
|
+
|
171
|
+
# possibilities:
|
172
|
+
# * module extended with setting
|
173
|
+
# => singleton gets attr_configuration and configurations
|
174
|
+
# => including modules and classes get nothing
|
175
|
+
# => extending modules and classes get nothing
|
176
|
+
# => instances of including and extending classes get nothing
|
177
|
+
# * module included with setting
|
178
|
+
# => singleton gets attr_configuration and configurations
|
179
|
+
# => including modules and classes get attr_configuration and configurations
|
180
|
+
# => instances of including classes get configurations
|
181
|
+
# => extending modules and classes get attr_configuration and configurations
|
182
|
+
# => instances of extending classes get nothing
|
183
|
+
module CascadingConfiguration::Array::ClassConfigurationMockModuleExtended
|
184
|
+
extend CascadingConfiguration::Array
|
185
|
+
# => singleton gets attr_configuration and configurations
|
186
|
+
respond_to?( :attr_module_configuration_array ).should == true
|
187
|
+
method( :attr_module_configuration_array ).should == method( :attr_class_configuration_array )
|
188
|
+
attr_module_configuration_array :configuration_setting
|
189
|
+
respond_to?( :configuration_setting ).should == true
|
190
|
+
configuration_setting.should == []
|
191
|
+
configuration_setting.push( :a_configuration )
|
192
|
+
configuration_setting.should == [ :a_configuration ]
|
193
|
+
instance_methods.include?( :configuration_setting ).should == false
|
194
|
+
# => including modules and classes get nothing
|
195
|
+
module SubmoduleIncluding
|
196
|
+
include CascadingConfiguration::Array::ClassConfigurationMockModuleExtended
|
197
|
+
instance_methods.include?( :configuration_setting ).should == false
|
198
|
+
respond_to?( :configuration_setting ).should == false
|
199
|
+
end
|
200
|
+
# => extending modules and classes get nothing
|
201
|
+
module SubmoduleExtending
|
202
|
+
extend CascadingConfiguration::Array::ClassConfigurationMockModuleExtended
|
203
|
+
instance_methods.include?( :configuration_setting ).should == false
|
204
|
+
respond_to?( :configuration_setting ).should == false
|
205
|
+
end
|
206
|
+
# => instances of including and extending classes get nothing
|
207
|
+
class ClassIncluding
|
208
|
+
include CascadingConfiguration::Array::ClassConfigurationMockModuleExtended
|
209
|
+
instance_methods.include?( :configuration_setting ).should == false
|
210
|
+
respond_to?( :configuration_setting ).should == false
|
211
|
+
end
|
212
|
+
class ClassExtending
|
213
|
+
extend CascadingConfiguration::Array::ClassConfigurationMockModuleExtended
|
214
|
+
instance_methods.include?( :configuration_setting ).should == false
|
215
|
+
respond_to?( :configuration_setting ).should == false
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
# * module included with setting
|
220
|
+
module CascadingConfiguration::Array::ClassConfigurationMockModuleIncluded
|
221
|
+
include CascadingConfiguration::Array
|
222
|
+
# => singleton gets attr_configuration and configurations
|
223
|
+
respond_to?( :attr_module_configuration_array ).should == true
|
224
|
+
attr_module_configuration_array :configuration_setting
|
225
|
+
respond_to?( :configuration_setting ).should == true
|
226
|
+
configuration_setting.should == []
|
227
|
+
configuration_setting.push( :a_configuration )
|
228
|
+
configuration_setting.should == [ :a_configuration ]
|
229
|
+
instance_methods.include?( :configuration_setting ).should == false
|
230
|
+
# => including modules and classes get attr_configuration and configurations
|
231
|
+
module SubmoduleIncluding
|
232
|
+
include CascadingConfiguration::Array::ClassConfigurationMockModuleIncluded
|
233
|
+
instance_methods.include?( :configuration_setting ).should == false
|
234
|
+
respond_to?( :configuration_setting ).should == true
|
235
|
+
configuration_setting.should == [ :a_configuration ]
|
236
|
+
configuration_setting.push( :another_configuration )
|
237
|
+
configuration_setting.should == [ :a_configuration, :another_configuration ]
|
238
|
+
instance_methods.include?( :configuration_setting ).should == false
|
239
|
+
end
|
240
|
+
# => extending modules and classes get attr_configuration and configurations
|
241
|
+
module SubmoduleExtending
|
242
|
+
extend CascadingConfiguration::Array::ClassConfigurationMockModuleIncluded
|
243
|
+
# if we're extended then we want to use the eigenclass ancestor chain
|
244
|
+
# - the first ancestor will be the extending module
|
245
|
+
# - the rest of the ancestors will be the extending module's include chain
|
246
|
+
respond_to?( :configuration_setting ).should == true
|
247
|
+
configuration_setting.should == [ :a_configuration ]
|
248
|
+
configuration_setting.push( :some_other_configuration )
|
249
|
+
configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
250
|
+
instance_methods.include?( :configuration_setting ).should == false
|
251
|
+
end
|
252
|
+
# => instances of including classes get configurations
|
253
|
+
class ClassIncluding
|
254
|
+
include CascadingConfiguration::Array::ClassConfigurationMockModuleIncluded
|
255
|
+
instance_methods.include?( :configuration_setting ).should == false
|
256
|
+
respond_to?( :configuration_setting ).should == true
|
257
|
+
configuration_setting.should == [ :a_configuration ]
|
258
|
+
configuration_setting.push( :some_other_configuration )
|
259
|
+
configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
260
|
+
end
|
261
|
+
setting_class_including_instance = ClassIncluding.new
|
262
|
+
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
263
|
+
# => instances of extending classes get nothing
|
264
|
+
class ClassExtending
|
265
|
+
extend CascadingConfiguration::Array::ClassConfigurationMockModuleIncluded
|
266
|
+
instance_methods.include?( :configuration_setting ).should == false
|
267
|
+
respond_to?( :configuration_setting ).should == true
|
268
|
+
configuration_setting.should == [ :a_configuration ]
|
269
|
+
configuration_setting.push( :some_other_configuration )
|
270
|
+
configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
271
|
+
end
|
272
|
+
setting_class_including_instance = ClassExtending.new
|
273
|
+
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
274
|
+
end
|
275
|
+
|
276
|
+
class CascadingConfiguration::Array::ClassConfigurationMockClass
|
277
|
+
include CascadingConfiguration::Array::ClassConfigurationMockModuleIncluded::SubmoduleIncluding
|
278
|
+
instance_methods.include?( :configuration_setting ).should == false
|
279
|
+
configuration_setting.should == [ :a_configuration, :another_configuration ]
|
280
|
+
configuration_setting.push( :some_other_configuration )
|
281
|
+
configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
282
|
+
end
|
283
|
+
object_instance_one = CascadingConfiguration::Array::ClassConfigurationMockClass.new
|
284
|
+
object_instance_one.respond_to?( :configuration_setting ).should == false
|
285
|
+
class CascadingConfiguration::Array::ClassConfigurationMockClassSub1 < CascadingConfiguration::Array::ClassConfigurationMockClass
|
286
|
+
instance_methods.include?( :configuration_setting ).should == false
|
287
|
+
configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
288
|
+
configuration_setting.delete( :a_configuration )
|
289
|
+
configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
290
|
+
end
|
291
|
+
object_instance_two = CascadingConfiguration::Array::ClassConfigurationMockClassSub1.new
|
292
|
+
object_instance_two.respond_to?( :configuration_setting ).should == false
|
293
|
+
class CascadingConfiguration::Array::ClassConfigurationMockClassSub2 < CascadingConfiguration::Array::ClassConfigurationMockClassSub1
|
294
|
+
instance_methods.include?( :configuration_setting ).should == false
|
295
|
+
configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
296
|
+
configuration_setting.push( :yet_another_configuration )
|
297
|
+
configuration_setting.should == [ :another_configuration, :some_other_configuration, :yet_another_configuration ]
|
298
|
+
end
|
299
|
+
|
300
|
+
# change ancestor setting
|
301
|
+
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
302
|
+
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.push( :a_yet_unused_configuration )
|
303
|
+
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
|
304
|
+
CascadingConfiguration::Array::ClassConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
|
305
|
+
|
306
|
+
# freeze ancestor setting
|
307
|
+
CascadingConfiguration::Array::ClassConfigurationMockClassSub1.configuration_setting.freeze!
|
308
|
+
CascadingConfiguration::Array::ClassConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
|
309
|
+
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.push( :non_cascading_configuration )
|
310
|
+
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :a_yet_unused_configuration, :another_configuration, :non_cascading_configuration, :some_other_configuration ]
|
311
|
+
CascadingConfiguration::Array::ClassConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
|
312
|
+
|
313
|
+
end
|
314
|
+
|
315
|
+
####################################
|
316
|
+
# attr_local_configuration_array #
|
317
|
+
####################################
|
318
|
+
|
319
|
+
it 'can define a local configuration array, which will not cascade' do
|
320
|
+
|
321
|
+
# possibilities:
|
322
|
+
# * module extended with setting
|
323
|
+
# => singleton gets attr_configuration and configurations
|
324
|
+
# => including modules and classes get nothing
|
325
|
+
# => extending modules and classes get nothing
|
326
|
+
# => instances of including and extending classes get nothing
|
327
|
+
# * module included with setting
|
328
|
+
# => singleton gets attr_configuration and configurations
|
329
|
+
# => including modules and classes get attr_configuration and configurations
|
330
|
+
# => instances of including classes get configurations
|
331
|
+
# => extending modules and classes get attr_configuration and configurations
|
332
|
+
# => instances of extending classes get nothing
|
333
|
+
module CascadingConfiguration::Array::LocalConfigurationMockModuleExtended
|
334
|
+
extend CascadingConfiguration::Array
|
335
|
+
# => singleton gets attr_configuration and configurations
|
336
|
+
respond_to?( :attr_local_configuration_array ).should == true
|
337
|
+
attr_local_configuration_array :configuration_setting
|
338
|
+
respond_to?( :configuration_setting ).should == true
|
339
|
+
configuration_setting.should == []
|
340
|
+
configuration_setting.push( :a_configuration )
|
341
|
+
configuration_setting.should == [ :a_configuration ]
|
342
|
+
instance_methods.include?( :configuration_setting ).should == false
|
343
|
+
# => including modules and classes get nothing
|
344
|
+
module SubmoduleIncluding
|
345
|
+
include CascadingConfiguration::Array::LocalConfigurationMockModuleExtended
|
346
|
+
instance_methods.include?( :configuration_setting ).should == false
|
347
|
+
respond_to?( :configuration_setting ).should == false
|
348
|
+
end
|
349
|
+
# => extending modules and classes get nothing
|
350
|
+
module SubmoduleExtending
|
351
|
+
extend CascadingConfiguration::Array::LocalConfigurationMockModuleExtended
|
352
|
+
instance_methods.include?( :configuration_setting ).should == false
|
353
|
+
respond_to?( :configuration_setting ).should == false
|
354
|
+
end
|
355
|
+
# => instances of including and extending classes get nothing
|
356
|
+
class ClassIncluding
|
357
|
+
include CascadingConfiguration::Array::LocalConfigurationMockModuleExtended
|
358
|
+
instance_methods.include?( :configuration_setting ).should == false
|
359
|
+
respond_to?( :configuration_setting ).should == false
|
360
|
+
end
|
361
|
+
class ClassExtending
|
362
|
+
extend CascadingConfiguration::Array::LocalConfigurationMockModuleExtended
|
363
|
+
instance_methods.include?( :configuration_setting ).should == false
|
364
|
+
respond_to?( :configuration_setting ).should == false
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
# * module included with setting
|
369
|
+
module CascadingConfiguration::Array::LocalConfigurationMockModuleIncluded
|
370
|
+
include CascadingConfiguration::Array
|
371
|
+
# => singleton gets attr_configuration and configurations
|
372
|
+
respond_to?( :attr_local_configuration_array ).should == true
|
373
|
+
attr_local_configuration_array :configuration_setting
|
374
|
+
respond_to?( :configuration_setting ).should == true
|
375
|
+
configuration_setting.should == []
|
376
|
+
configuration_setting.push( :a_configuration )
|
377
|
+
configuration_setting.should == [ :a_configuration ]
|
378
|
+
instance_methods.include?( :configuration_setting ).should == false
|
379
|
+
# => including modules and classes get attr_configuration and configurations
|
380
|
+
module SubmoduleIncluding
|
381
|
+
include CascadingConfiguration::Array::LocalConfigurationMockModuleIncluded
|
382
|
+
instance_methods.include?( :configuration_setting ).should == false
|
383
|
+
respond_to?( :configuration_setting ).should == false
|
384
|
+
instance_methods.include?( :configuration_setting ).should == false
|
385
|
+
end
|
386
|
+
# => extending modules and classes get attr_configuration and configurations
|
387
|
+
module SubmoduleExtending
|
388
|
+
extend CascadingConfiguration::Array::LocalConfigurationMockModuleIncluded
|
389
|
+
# if we're extended then we want to use the eigenclass ancestor chain
|
390
|
+
# - the first ancestor will be the extending module
|
391
|
+
# - the rest of the ancestors will be the extending module's include chain
|
392
|
+
respond_to?( :configuration_setting ).should == false
|
393
|
+
instance_methods.include?( :configuration_setting ).should == false
|
394
|
+
end
|
395
|
+
# => instances of including classes get configurations
|
396
|
+
class ClassIncluding
|
397
|
+
include CascadingConfiguration::Array::LocalConfigurationMockModuleIncluded
|
398
|
+
instance_methods.include?( :configuration_setting ).should == false
|
399
|
+
respond_to?( :configuration_setting ).should == false
|
400
|
+
end
|
401
|
+
setting_class_including_instance = ClassIncluding.new
|
402
|
+
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
403
|
+
# => instances of extending classes get nothing
|
404
|
+
class ClassExtending
|
405
|
+
extend CascadingConfiguration::Array::LocalConfigurationMockModuleIncluded
|
406
|
+
instance_methods.include?( :configuration_setting ).should == false
|
407
|
+
respond_to?( :configuration_setting ).should == false
|
408
|
+
end
|
409
|
+
setting_class_including_instance = ClassExtending.new
|
410
|
+
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
411
|
+
end
|
412
|
+
|
413
|
+
class CascadingConfiguration::Array::LocalConfigurationMockClass
|
414
|
+
include CascadingConfiguration::Array::LocalConfigurationMockModuleIncluded::SubmoduleIncluding
|
415
|
+
instance_methods.include?( :configuration_setting ).should == false
|
416
|
+
respond_to?( :configuration_setting ).should == false
|
417
|
+
end
|
418
|
+
object_instance_one = CascadingConfiguration::Array::LocalConfigurationMockClass.new
|
419
|
+
object_instance_one.respond_to?( :configuration_setting ).should == false
|
420
|
+
class CascadingConfiguration::Array::LocalConfigurationMockClassSub1 < CascadingConfiguration::Array::LocalConfigurationMockClass
|
421
|
+
instance_methods.include?( :configuration_setting ).should == false
|
422
|
+
respond_to?( :configuration_setting ).should == false
|
423
|
+
end
|
424
|
+
object_instance_two = CascadingConfiguration::Array::LocalConfigurationMockClassSub1.new
|
425
|
+
object_instance_two.respond_to?( :configuration_setting ).should == false
|
426
|
+
class CascadingConfiguration::Array::LocalConfigurationMockClassSub2 < CascadingConfiguration::Array::LocalConfigurationMockClassSub1
|
427
|
+
instance_methods.include?( :configuration_setting ).should == false
|
428
|
+
respond_to?( :configuration_setting ).should == false
|
429
|
+
end
|
430
|
+
|
431
|
+
end
|
163
432
|
|
164
433
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 1.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 1.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Asher
|
@@ -41,7 +41,7 @@ extra_rdoc_files: []
|
|
41
41
|
files:
|
42
42
|
- lib/cascading-configuration-array/CascadingConfiguration/_private_/CompositingArray.rb
|
43
43
|
- lib/cascading-configuration-array/CascadingConfiguration/_private_/LocalConfigurationArray.rb
|
44
|
-
- lib/cascading-configuration-array/CascadingConfiguration/Array/
|
44
|
+
- lib/cascading-configuration-array/CascadingConfiguration/Array/AccessorDefinitionMethods.rb
|
45
45
|
- lib/cascading-configuration-array/CascadingConfiguration/Array/Interface.rb
|
46
46
|
- lib/cascading-configuration-array/CascadingConfiguration/Array/ModuleInclusionExtensionSupport.rb
|
47
47
|
- lib/cascading-configuration-array/CascadingConfiguration/Array.rb
|
@@ -49,7 +49,7 @@ files:
|
|
49
49
|
- lib/cascading-configuration-array/CascadingConfiguration/CompositingArray.rb
|
50
50
|
- lib/cascading-configuration-array/CascadingConfiguration/LocalConfigurationArray.rb
|
51
51
|
- lib/cascading-configuration-array.rb
|
52
|
-
- spec/CascadingConfiguration/Array/
|
52
|
+
- spec/CascadingConfiguration/Array/AccessorDefinitionMethods_spec.rb
|
53
53
|
- spec/CascadingConfiguration/Array_spec.rb
|
54
54
|
- spec/CascadingConfiguration/CompositingArray_spec.rb
|
55
55
|
- spec/CascadingConfiguration/LocalConfigurationArray_spec.rb
|