cascading-configuration-array 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +138 -0
- data/lib/cascading-configuration-array.rb +33 -0
- data/lib/cascading-configuration-array/CascadingConfiguration/CascadingCompositeArray.rb +215 -0
- data/lib/cascading-configuration-array/CascadingConfiguration/CascadingCompositeArray/Instance.rb +37 -0
- data/lib/cascading-configuration-array/CascadingConfiguration/CascadingCompositeArray/_private_/Instance.rb +16 -0
- data/lib/cascading-configuration-array/CascadingConfiguration/ConfigurationArray.rb +166 -0
- data/lib/cascading-configuration-array/CascadingConfiguration/ConfigurationSettingsArray.rb +21 -0
- data/lib/cascading-configuration-array/CascadingConfiguration/ConfigurationSettingsArray/Accessors.rb +41 -0
- data/lib/cascading-configuration-array/CascadingConfiguration/ConfigurationSettingsArray/ClassInstance.rb +17 -0
- data/lib/cascading-configuration-array/CascadingConfiguration/ConfigurationSettingsArray/ModuleInstance.rb +20 -0
- data/lib/cascading-configuration-array/CascadingConfiguration/_private_/CascadingCompositeArray.rb +57 -0
- data/lib/cascading-configuration-array/CascadingConfiguration/_private_/ConfigurationArray.rb +26 -0
- data/spec/CascadingConfiguration/CascadingCompositeArray_spec.rb +519 -0
- data/spec/CascadingConfiguration/ConfigurationArray_spec.rb +155 -0
- data/spec/CascadingConfiguration/ConfigurationSettingsArray/Accessors_spec.rb +28 -0
- data/spec/CascadingConfiguration/ConfigurationSettingsArray_spec.rb +75 -0
- metadata +91 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
module CascadingConfiguration::ConfigurationSettingsArray
|
3
|
+
|
4
|
+
###################
|
5
|
+
# self.included #
|
6
|
+
###################
|
7
|
+
|
8
|
+
def self.included( class_or_module )
|
9
|
+
class_or_module.instance_eval do
|
10
|
+
include CascadingConfiguration::ConfigurationVariable
|
11
|
+
extend CascadingConfiguration::ConfigurationSettingsArray
|
12
|
+
extend CascadingConfiguration::ConfigurationSettingsArray::Accessors
|
13
|
+
extend CascadingConfiguration::ConfigurationSettingsArray::ClassInstance
|
14
|
+
include CascadingConfiguration::CascadingCompositeArray::Instance
|
15
|
+
unless is_a?( Class )
|
16
|
+
extend CascadingConfiguration::ConfigurationSettingsArray::ModuleInstance
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
module CascadingConfiguration::ConfigurationSettingsArray::Accessors
|
3
|
+
|
4
|
+
#######################################
|
5
|
+
# define_configuration_array_setter #
|
6
|
+
#######################################
|
7
|
+
|
8
|
+
def define_configuration_array_setter( configuration_name )
|
9
|
+
[ self, eigenclass ].each do |klass_or_eigenclass|
|
10
|
+
klass_or_eigenclass.class_eval do
|
11
|
+
configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
|
12
|
+
define_method( configuration_setter_name ) do |array|
|
13
|
+
composite_array = composite_array_for_cascading_configuration( configuration_name )
|
14
|
+
# we want the array to supplant existing config
|
15
|
+
# clear the array (excludes everything explicitly)
|
16
|
+
composite_array.clear
|
17
|
+
# push array elements (removes anything excluded from exclude)
|
18
|
+
composite_array.push( *array )
|
19
|
+
return composite_array
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
#######################################
|
26
|
+
# define_configuration_array_getter #
|
27
|
+
#######################################
|
28
|
+
|
29
|
+
def define_configuration_array_getter( configuration_name )
|
30
|
+
configuration_getter_name = configuration_name
|
31
|
+
[ self, eigenclass ].each do |klass_or_eigenclass|
|
32
|
+
klass_or_eigenclass.class_eval do
|
33
|
+
define_method( configuration_getter_name ) do
|
34
|
+
composite_array = composite_array_for_cascading_configuration( configuration_name )
|
35
|
+
return composite_array
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
module CascadingConfiguration::ConfigurationSettingsArray::ClassInstance
|
3
|
+
|
4
|
+
##############################
|
5
|
+
# attr_configuration_array #
|
6
|
+
##############################
|
7
|
+
|
8
|
+
def attr_configuration_array( *property_names )
|
9
|
+
property_names.each do |this_property_name|
|
10
|
+
# define configuration setter
|
11
|
+
define_configuration_array_setter( this_property_name )
|
12
|
+
# define configuration getter
|
13
|
+
define_configuration_array_getter( this_property_name )
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
module CascadingConfiguration::ConfigurationSettingsArray::ModuleInstance
|
3
|
+
|
4
|
+
##############
|
5
|
+
# included #
|
6
|
+
##############
|
7
|
+
|
8
|
+
def included( class_or_module )
|
9
|
+
self_module = self
|
10
|
+
class_or_module.instance_eval do
|
11
|
+
include CascadingConfiguration::ConfigurationSettingsArray
|
12
|
+
# when we extend a module (which has happened if we got here)
|
13
|
+
# then we need to make sure when the module we are extending is included
|
14
|
+
# * CascadingConfiguration is included
|
15
|
+
# * the module we extended is used to extend the class/module that included
|
16
|
+
extend self_module
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/lib/cascading-configuration-array/CascadingConfiguration/_private_/CascadingCompositeArray.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
|
2
|
+
class CascadingConfiguration::CascadingCompositeArray < Array
|
3
|
+
|
4
|
+
###########################################################################################################
|
5
|
+
private ###############################################################################################
|
6
|
+
###########################################################################################################
|
7
|
+
|
8
|
+
########################################
|
9
|
+
# update_self_as_cascading_composite #
|
10
|
+
########################################
|
11
|
+
|
12
|
+
def update_self_as_cascading_composite
|
13
|
+
# start fresh
|
14
|
+
super_clear
|
15
|
+
# add parent config
|
16
|
+
super_push( *@parent_composite_array ) if @parent_composite_array
|
17
|
+
# add additional local config
|
18
|
+
super_push( *@local_cascading_array )
|
19
|
+
# remove local exclude
|
20
|
+
super_delete( *@local_cascading_array.exclude_array ) unless @local_cascading_array.exclude_array.empty?
|
21
|
+
# notify children to update their composite status
|
22
|
+
update_child_composite_arrays
|
23
|
+
return self
|
24
|
+
end
|
25
|
+
|
26
|
+
######################################
|
27
|
+
# update_adding_composite_elements #
|
28
|
+
######################################
|
29
|
+
|
30
|
+
def update_adding_composite_elements( *elements_to_cascade )
|
31
|
+
super_push( *elements_to_cascade )
|
32
|
+
sort!.uniq!
|
33
|
+
update_child_composite_arrays
|
34
|
+
end
|
35
|
+
|
36
|
+
########################################
|
37
|
+
# update_removing_composite_elements #
|
38
|
+
########################################
|
39
|
+
|
40
|
+
def update_removing_composite_elements( *elements_to_exclude )
|
41
|
+
elements_to_exclude.each do |this_excluded_element|
|
42
|
+
super_delete( this_excluded_element )
|
43
|
+
end
|
44
|
+
update_child_composite_arrays
|
45
|
+
end
|
46
|
+
|
47
|
+
###################################
|
48
|
+
# update_child_composite_arrays #
|
49
|
+
###################################
|
50
|
+
|
51
|
+
def update_child_composite_arrays
|
52
|
+
@child_composite_arrays.each do |this_composite_array|
|
53
|
+
this_composite_array.instance_eval { update_self_as_cascading_composite }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
class CascadingConfiguration::ConfigurationArray < Array
|
3
|
+
|
4
|
+
###########################################################################################################
|
5
|
+
private ###############################################################################################
|
6
|
+
###########################################################################################################
|
7
|
+
|
8
|
+
##########################
|
9
|
+
# add_to_exclude_array #
|
10
|
+
##########################
|
11
|
+
|
12
|
+
def add_to_exclude_array( *elements )
|
13
|
+
@exclude_array += elements
|
14
|
+
@exclude_array.sort!.uniq!
|
15
|
+
end
|
16
|
+
|
17
|
+
###############################
|
18
|
+
# remove_from_exclude_array #
|
19
|
+
###############################
|
20
|
+
|
21
|
+
def remove_from_exclude_array( *elements )
|
22
|
+
@exclude_array -= elements
|
23
|
+
@exclude_array.sort!.uniq!
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,519 @@
|
|
1
|
+
|
2
|
+
require_relative '../../lib/cascading-configuration-array.rb'
|
3
|
+
|
4
|
+
describe CascadingConfiguration::CascadingCompositeArray do
|
5
|
+
|
6
|
+
#########
|
7
|
+
# []= #
|
8
|
+
#########
|
9
|
+
|
10
|
+
it 'can add elements' do
|
11
|
+
# primary class
|
12
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock01
|
13
|
+
include CascadingConfiguration::ConfigurationVariable
|
14
|
+
include CascadingConfiguration::CascadingCompositeArray::Instance
|
15
|
+
end
|
16
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock01
|
17
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
18
|
+
cascading_composite_array[0] = :some_setting
|
19
|
+
cascading_composite_array.local_cascading_array.should == [ :some_setting ]
|
20
|
+
cascading_composite_array.should == [ :some_setting ]
|
21
|
+
cascading_composite_array[1] = :other_setting
|
22
|
+
cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
|
23
|
+
cascading_composite_array.should == [ :other_setting, :some_setting ]
|
24
|
+
# instance
|
25
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock01.new
|
26
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
27
|
+
cascading_composite_array.local_cascading_array.should == []
|
28
|
+
cascading_composite_array[0] = :another_setting
|
29
|
+
cascading_composite_array.local_cascading_array.should == [ :another_setting ]
|
30
|
+
cascading_composite_array.should == [ :another_setting, :other_setting, :some_setting ]
|
31
|
+
# inheriting class
|
32
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock01sub1 < CascadingConfiguration::CascadingCompositeArray::Mock01
|
33
|
+
end
|
34
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock01sub1
|
35
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
36
|
+
cascading_composite_array.local_cascading_array.should == []
|
37
|
+
cascading_composite_array[0] = :yet_another_setting
|
38
|
+
cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
|
39
|
+
cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
|
40
|
+
# instance
|
41
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock01sub1.new
|
42
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
43
|
+
cascading_composite_array.local_cascading_array.should == []
|
44
|
+
cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
|
45
|
+
cascading_composite_array[0] = :and_still_another_setting
|
46
|
+
cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
|
47
|
+
cascading_composite_array.should == [ :and_still_another_setting, :other_setting, :some_setting, :yet_another_setting ]
|
48
|
+
end
|
49
|
+
|
50
|
+
########
|
51
|
+
# << #
|
52
|
+
########
|
53
|
+
|
54
|
+
it 'can add elements' do
|
55
|
+
# primary class
|
56
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock02
|
57
|
+
include CascadingConfiguration::ConfigurationVariable
|
58
|
+
include CascadingConfiguration::CascadingCompositeArray::Instance
|
59
|
+
end
|
60
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock02
|
61
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
62
|
+
cascading_composite_array << :some_setting
|
63
|
+
cascading_composite_array.local_cascading_array.should == [ :some_setting ]
|
64
|
+
cascading_composite_array.should == [ :some_setting ]
|
65
|
+
cascading_composite_array << :other_setting
|
66
|
+
cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
|
67
|
+
cascading_composite_array.should == [ :other_setting, :some_setting ]
|
68
|
+
# instance
|
69
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock02.new
|
70
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
71
|
+
cascading_composite_array.local_cascading_array.should == []
|
72
|
+
cascading_composite_array << :another_setting
|
73
|
+
cascading_composite_array.local_cascading_array.should == [ :another_setting ]
|
74
|
+
cascading_composite_array.should == [ :another_setting, :other_setting, :some_setting ]
|
75
|
+
# inheriting class
|
76
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock02sub1 < CascadingConfiguration::CascadingCompositeArray::Mock02
|
77
|
+
end
|
78
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock02sub1
|
79
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
80
|
+
cascading_composite_array.local_cascading_array.should == []
|
81
|
+
cascading_composite_array << :yet_another_setting
|
82
|
+
cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
|
83
|
+
cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
|
84
|
+
# instance
|
85
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock02sub1.new
|
86
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
87
|
+
cascading_composite_array.local_cascading_array.should == []
|
88
|
+
cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
|
89
|
+
cascading_composite_array << :and_still_another_setting
|
90
|
+
cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
|
91
|
+
cascading_composite_array.should == [ :and_still_another_setting, :other_setting, :some_setting, :yet_another_setting ]
|
92
|
+
end
|
93
|
+
|
94
|
+
#######
|
95
|
+
# + #
|
96
|
+
#######
|
97
|
+
|
98
|
+
it 'can add elements' do
|
99
|
+
# primary class
|
100
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock03
|
101
|
+
include CascadingConfiguration::ConfigurationVariable
|
102
|
+
include CascadingConfiguration::CascadingCompositeArray::Instance
|
103
|
+
end
|
104
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock03
|
105
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
106
|
+
cascading_composite_array += :some_setting
|
107
|
+
cascading_composite_array.local_cascading_array.should == [ :some_setting ]
|
108
|
+
cascading_composite_array.should == [ :some_setting ]
|
109
|
+
cascading_composite_array += :other_setting
|
110
|
+
cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
|
111
|
+
cascading_composite_array.should == [ :other_setting, :some_setting ]
|
112
|
+
# instance
|
113
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock03.new
|
114
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
115
|
+
cascading_composite_array.local_cascading_array.should == []
|
116
|
+
cascading_composite_array += :another_setting
|
117
|
+
cascading_composite_array.local_cascading_array.should == [ :another_setting ]
|
118
|
+
cascading_composite_array.should == [ :another_setting, :other_setting, :some_setting ]
|
119
|
+
# inheriting class
|
120
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock03sub1 < CascadingConfiguration::CascadingCompositeArray::Mock03
|
121
|
+
end
|
122
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock03sub1
|
123
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
124
|
+
cascading_composite_array.local_cascading_array.should == []
|
125
|
+
cascading_composite_array += :yet_another_setting
|
126
|
+
cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
|
127
|
+
cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
|
128
|
+
# instance
|
129
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock03sub1.new
|
130
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
131
|
+
cascading_composite_array.local_cascading_array.should == []
|
132
|
+
cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
|
133
|
+
cascading_composite_array += :and_still_another_setting
|
134
|
+
cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
|
135
|
+
cascading_composite_array.should == [ :and_still_another_setting, :other_setting, :some_setting, :yet_another_setting ]
|
136
|
+
end
|
137
|
+
|
138
|
+
############
|
139
|
+
# concat #
|
140
|
+
############
|
141
|
+
|
142
|
+
it 'can add elements' do
|
143
|
+
# primary class
|
144
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock04
|
145
|
+
include CascadingConfiguration::ConfigurationVariable
|
146
|
+
include CascadingConfiguration::CascadingCompositeArray::Instance
|
147
|
+
end
|
148
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock04
|
149
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
150
|
+
cascading_composite_array.concat [ :some_setting ]
|
151
|
+
cascading_composite_array.local_cascading_array.should == [ :some_setting ]
|
152
|
+
cascading_composite_array.should == [ :some_setting ]
|
153
|
+
cascading_composite_array.concat [ :other_setting ]
|
154
|
+
cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
|
155
|
+
cascading_composite_array.should == [ :other_setting, :some_setting ]
|
156
|
+
# instance
|
157
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock04.new
|
158
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
159
|
+
cascading_composite_array.local_cascading_array.should == []
|
160
|
+
cascading_composite_array.concat [ :another_setting ]
|
161
|
+
cascading_composite_array.local_cascading_array.should == [ :another_setting ]
|
162
|
+
cascading_composite_array.should == [ :another_setting, :other_setting, :some_setting ]
|
163
|
+
# inheriting class
|
164
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock04sub1 < CascadingConfiguration::CascadingCompositeArray::Mock04
|
165
|
+
end
|
166
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock04sub1
|
167
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
168
|
+
cascading_composite_array.local_cascading_array.should == []
|
169
|
+
cascading_composite_array.concat [ :yet_another_setting ]
|
170
|
+
cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
|
171
|
+
cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
|
172
|
+
# instance
|
173
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock04sub1.new
|
174
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
175
|
+
cascading_composite_array.local_cascading_array.should == []
|
176
|
+
cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
|
177
|
+
cascading_composite_array.concat [ :and_still_another_setting ]
|
178
|
+
cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
|
179
|
+
cascading_composite_array.should == [ :and_still_another_setting, :other_setting, :some_setting, :yet_another_setting ]
|
180
|
+
end
|
181
|
+
|
182
|
+
##########
|
183
|
+
# push #
|
184
|
+
##########
|
185
|
+
|
186
|
+
it 'can add elements' do
|
187
|
+
# primary class
|
188
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock05
|
189
|
+
include CascadingConfiguration::ConfigurationVariable
|
190
|
+
include CascadingConfiguration::CascadingCompositeArray::Instance
|
191
|
+
end
|
192
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock05
|
193
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
194
|
+
cascading_composite_array.push :some_setting
|
195
|
+
cascading_composite_array.local_cascading_array.should == [ :some_setting ]
|
196
|
+
cascading_composite_array.should == [ :some_setting ]
|
197
|
+
cascading_composite_array.push :other_setting
|
198
|
+
cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
|
199
|
+
cascading_composite_array.should == [ :other_setting, :some_setting ]
|
200
|
+
# instance
|
201
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock05.new
|
202
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
203
|
+
cascading_composite_array.local_cascading_array.should == []
|
204
|
+
cascading_composite_array.push :another_setting
|
205
|
+
cascading_composite_array.local_cascading_array.should == [ :another_setting ]
|
206
|
+
cascading_composite_array.should == [ :another_setting, :other_setting, :some_setting ]
|
207
|
+
# inheriting class
|
208
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock05sub1 < CascadingConfiguration::CascadingCompositeArray::Mock05
|
209
|
+
end
|
210
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock05sub1
|
211
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
212
|
+
cascading_composite_array.local_cascading_array.should == []
|
213
|
+
cascading_composite_array.push :yet_another_setting
|
214
|
+
cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
|
215
|
+
cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
|
216
|
+
# instance
|
217
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock05sub1.new
|
218
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
219
|
+
cascading_composite_array.local_cascading_array.should == []
|
220
|
+
cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
|
221
|
+
cascading_composite_array.push :and_still_another_setting
|
222
|
+
cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
|
223
|
+
cascading_composite_array.should == [ :and_still_another_setting, :other_setting, :some_setting, :yet_another_setting ]
|
224
|
+
end
|
225
|
+
|
226
|
+
#######
|
227
|
+
# - #
|
228
|
+
#######
|
229
|
+
|
230
|
+
it 'can exclude elements' do
|
231
|
+
# primary class
|
232
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock06
|
233
|
+
include CascadingConfiguration::ConfigurationVariable
|
234
|
+
include CascadingConfiguration::CascadingCompositeArray::Instance
|
235
|
+
end
|
236
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock06
|
237
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
238
|
+
cascading_composite_array.push( :other_setting, :some_setting )
|
239
|
+
cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
|
240
|
+
cascading_composite_array.should == [ :other_setting, :some_setting ]
|
241
|
+
cascading_composite_array -= [ :other_setting ]
|
242
|
+
cascading_composite_array.local_cascading_array.should == [ :some_setting ]
|
243
|
+
cascading_composite_array.should == [ :some_setting ]
|
244
|
+
# instance
|
245
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock06.new
|
246
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
247
|
+
cascading_composite_array.local_cascading_array.should == []
|
248
|
+
cascading_composite_array += [ :another_setting ]
|
249
|
+
cascading_composite_array.local_cascading_array.should == [ :another_setting ]
|
250
|
+
cascading_composite_array -= [ :some_setting ]
|
251
|
+
cascading_composite_array.should == [ :another_setting ]
|
252
|
+
# inheriting class
|
253
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock06sub1 < CascadingConfiguration::CascadingCompositeArray::Mock06
|
254
|
+
end
|
255
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock06sub1
|
256
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
257
|
+
cascading_composite_array.local_cascading_array.should == []
|
258
|
+
cascading_composite_array += [ :yet_another_setting ]
|
259
|
+
cascading_composite_array -= [ :some_setting ]
|
260
|
+
cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
|
261
|
+
cascading_composite_array.should == [ :yet_another_setting ]
|
262
|
+
# instance
|
263
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock06sub1.new
|
264
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
265
|
+
cascading_composite_array.local_cascading_array.should == []
|
266
|
+
cascading_composite_array.should == [ :yet_another_setting ]
|
267
|
+
cascading_composite_array += [ :and_still_another_setting ]
|
268
|
+
cascading_composite_array -= [ :yet_another_setting ]
|
269
|
+
cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
|
270
|
+
cascading_composite_array.should == [ :and_still_another_setting ]
|
271
|
+
end
|
272
|
+
|
273
|
+
############
|
274
|
+
# delete #
|
275
|
+
############
|
276
|
+
|
277
|
+
it 'can exclude elements' do
|
278
|
+
# primary class
|
279
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock07
|
280
|
+
include CascadingConfiguration::ConfigurationVariable
|
281
|
+
include CascadingConfiguration::CascadingCompositeArray::Instance
|
282
|
+
end
|
283
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock07
|
284
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
285
|
+
cascading_composite_array.push( :other_setting, :some_setting )
|
286
|
+
cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
|
287
|
+
cascading_composite_array.should == [ :other_setting, :some_setting ]
|
288
|
+
cascading_composite_array.delete( :other_setting )
|
289
|
+
cascading_composite_array.local_cascading_array.should == [ :some_setting ]
|
290
|
+
cascading_composite_array.should == [ :some_setting ]
|
291
|
+
# instance
|
292
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock07.new
|
293
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
294
|
+
cascading_composite_array.local_cascading_array.should == []
|
295
|
+
cascading_composite_array += [ :another_setting ]
|
296
|
+
cascading_composite_array.local_cascading_array.should == [ :another_setting ]
|
297
|
+
cascading_composite_array.delete( :some_setting )
|
298
|
+
cascading_composite_array.should == [ :another_setting ]
|
299
|
+
# inheriting class
|
300
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock07sub1 < CascadingConfiguration::CascadingCompositeArray::Mock07
|
301
|
+
end
|
302
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock07sub1
|
303
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
304
|
+
cascading_composite_array.local_cascading_array.should == []
|
305
|
+
cascading_composite_array += [ :yet_another_setting ]
|
306
|
+
cascading_composite_array.delete( :some_setting )
|
307
|
+
cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
|
308
|
+
cascading_composite_array.should == [ :yet_another_setting ]
|
309
|
+
# instance
|
310
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock07sub1.new
|
311
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
312
|
+
cascading_composite_array.local_cascading_array.should == []
|
313
|
+
cascading_composite_array.should == [ :yet_another_setting ]
|
314
|
+
cascading_composite_array += [ :and_still_another_setting ]
|
315
|
+
cascading_composite_array.delete( :yet_another_setting )
|
316
|
+
cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
|
317
|
+
cascading_composite_array.should == [ :and_still_another_setting ]
|
318
|
+
end
|
319
|
+
|
320
|
+
#########
|
321
|
+
# pop #
|
322
|
+
#########
|
323
|
+
|
324
|
+
it 'can pop the final element' do
|
325
|
+
# primary class
|
326
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock08
|
327
|
+
include CascadingConfiguration::ConfigurationVariable
|
328
|
+
include CascadingConfiguration::CascadingCompositeArray::Instance
|
329
|
+
end
|
330
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock08
|
331
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
332
|
+
cascading_composite_array.push( :other_setting, :some_setting )
|
333
|
+
cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
|
334
|
+
cascading_composite_array.should == [ :other_setting, :some_setting ]
|
335
|
+
cascading_composite_array.pop.should == :some_setting
|
336
|
+
cascading_composite_array.local_cascading_array.should == [ :other_setting ]
|
337
|
+
cascading_composite_array.should == [ :other_setting ]
|
338
|
+
# instance
|
339
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock08.new
|
340
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
341
|
+
cascading_composite_array.local_cascading_array.should == []
|
342
|
+
cascading_composite_array += :another_setting
|
343
|
+
cascading_composite_array.local_cascading_array.should == [ :another_setting ]
|
344
|
+
cascading_composite_array.pop.should == :other_setting
|
345
|
+
cascading_composite_array.should == [ :another_setting ]
|
346
|
+
# inheriting class
|
347
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock08sub1 < CascadingConfiguration::CascadingCompositeArray::Mock08
|
348
|
+
end
|
349
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock08sub1
|
350
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
351
|
+
cascading_composite_array.local_cascading_array.should == []
|
352
|
+
cascading_composite_array.pop.should == :other_setting
|
353
|
+
cascading_composite_array.should == []
|
354
|
+
cascading_composite_array += :yet_another_setting
|
355
|
+
cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
|
356
|
+
cascading_composite_array.should == [ :yet_another_setting ]
|
357
|
+
# instance
|
358
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock08sub1.new
|
359
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
360
|
+
cascading_composite_array.local_cascading_array.should == []
|
361
|
+
cascading_composite_array.should == [ :yet_another_setting ]
|
362
|
+
cascading_composite_array.pop.should == :yet_another_setting
|
363
|
+
cascading_composite_array.should == []
|
364
|
+
cascading_composite_array += :and_still_another_setting
|
365
|
+
cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
|
366
|
+
cascading_composite_array.should == [ :and_still_another_setting ]
|
367
|
+
end
|
368
|
+
|
369
|
+
###########
|
370
|
+
# shift #
|
371
|
+
###########
|
372
|
+
|
373
|
+
it 'can shift the first element' do
|
374
|
+
# primary class
|
375
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock09
|
376
|
+
include CascadingConfiguration::ConfigurationVariable
|
377
|
+
include CascadingConfiguration::CascadingCompositeArray::Instance
|
378
|
+
end
|
379
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock09
|
380
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
381
|
+
cascading_composite_array.push( :other_setting, :some_setting )
|
382
|
+
cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
|
383
|
+
cascading_composite_array.should == [ :other_setting, :some_setting ]
|
384
|
+
cascading_composite_array.shift
|
385
|
+
cascading_composite_array.local_cascading_array.should == [ :some_setting ]
|
386
|
+
cascading_composite_array.should == [ :some_setting ]
|
387
|
+
# instance
|
388
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock09.new
|
389
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
390
|
+
cascading_composite_array.local_cascading_array.should == []
|
391
|
+
cascading_composite_array.shift
|
392
|
+
cascading_composite_array.should == []
|
393
|
+
cascading_composite_array += :another_setting
|
394
|
+
cascading_composite_array.local_cascading_array.should == [ :another_setting ]
|
395
|
+
cascading_composite_array.should == [ :another_setting ]
|
396
|
+
# inheriting class
|
397
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock09sub1 < CascadingConfiguration::CascadingCompositeArray::Mock09
|
398
|
+
end
|
399
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock09sub1
|
400
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
401
|
+
cascading_composite_array.local_cascading_array.should == []
|
402
|
+
cascading_composite_array.shift
|
403
|
+
cascading_composite_array.should == []
|
404
|
+
cascading_composite_array += :yet_another_setting
|
405
|
+
cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
|
406
|
+
cascading_composite_array.should == [ :yet_another_setting ]
|
407
|
+
# instance
|
408
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock09sub1.new
|
409
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
410
|
+
cascading_composite_array.local_cascading_array.should == []
|
411
|
+
cascading_composite_array.should == [ :yet_another_setting ]
|
412
|
+
cascading_composite_array.shift
|
413
|
+
cascading_composite_array.should == []
|
414
|
+
cascading_composite_array += :and_still_another_setting
|
415
|
+
cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
|
416
|
+
cascading_composite_array.should == [ :and_still_another_setting ]
|
417
|
+
end
|
418
|
+
|
419
|
+
############
|
420
|
+
# slice! #
|
421
|
+
############
|
422
|
+
|
423
|
+
it 'can slice elements' do
|
424
|
+
# primary class
|
425
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock10
|
426
|
+
include CascadingConfiguration::ConfigurationVariable
|
427
|
+
include CascadingConfiguration::CascadingCompositeArray::Instance
|
428
|
+
end
|
429
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock10
|
430
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
431
|
+
cascading_composite_array.push( :other_setting, :some_setting )
|
432
|
+
cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
|
433
|
+
cascading_composite_array.should == [ :other_setting, :some_setting ]
|
434
|
+
cascading_composite_array.slice!( 0, 1 ).should == [ :other_setting ]
|
435
|
+
cascading_composite_array.local_cascading_array.should == [ :some_setting ]
|
436
|
+
cascading_composite_array.should == [ :some_setting ]
|
437
|
+
# instance
|
438
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock10.new
|
439
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
440
|
+
cascading_composite_array.local_cascading_array.should == []
|
441
|
+
cascading_composite_array.slice!( 0, 1 ).should == [ :some_setting ]
|
442
|
+
cascading_composite_array.should == []
|
443
|
+
cascading_composite_array += :another_setting
|
444
|
+
cascading_composite_array.local_cascading_array.should == [ :another_setting ]
|
445
|
+
cascading_composite_array.should == [ :another_setting ]
|
446
|
+
# inheriting class
|
447
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock10sub1 < CascadingConfiguration::CascadingCompositeArray::Mock10
|
448
|
+
end
|
449
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock10sub1
|
450
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
451
|
+
cascading_composite_array.local_cascading_array.should == []
|
452
|
+
cascading_composite_array.slice!( 0, 1 ).should == [ :some_setting ]
|
453
|
+
cascading_composite_array.should == []
|
454
|
+
cascading_composite_array += :yet_another_setting
|
455
|
+
cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
|
456
|
+
cascading_composite_array.should == [ :yet_another_setting ]
|
457
|
+
# instance
|
458
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock10sub1.new
|
459
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
460
|
+
cascading_composite_array.local_cascading_array.should == []
|
461
|
+
cascading_composite_array.should == [ :yet_another_setting ]
|
462
|
+
cascading_composite_array.slice!( 0, 1 ).should == [ :yet_another_setting ]
|
463
|
+
cascading_composite_array.should == []
|
464
|
+
cascading_composite_array += :and_still_another_setting
|
465
|
+
cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
|
466
|
+
cascading_composite_array.should == [ :and_still_another_setting ]
|
467
|
+
end
|
468
|
+
|
469
|
+
###########
|
470
|
+
# clear #
|
471
|
+
###########
|
472
|
+
|
473
|
+
it 'can clear, causing present elements to be excluded' do
|
474
|
+
# primary class
|
475
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock11
|
476
|
+
include CascadingConfiguration::ConfigurationVariable
|
477
|
+
include CascadingConfiguration::CascadingCompositeArray::Instance
|
478
|
+
end
|
479
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock11
|
480
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
481
|
+
cascading_composite_array.push( :other_setting, :some_setting )
|
482
|
+
cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
|
483
|
+
cascading_composite_array.should == [ :other_setting, :some_setting ]
|
484
|
+
cascading_composite_array.clear
|
485
|
+
cascading_composite_array.local_cascading_array.should == []
|
486
|
+
cascading_composite_array.should == []
|
487
|
+
# instance
|
488
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock11.new
|
489
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
490
|
+
cascading_composite_array.local_cascading_array.should == []
|
491
|
+
cascading_composite_array.clear
|
492
|
+
cascading_composite_array.should == []
|
493
|
+
cascading_composite_array += :another_setting
|
494
|
+
cascading_composite_array.local_cascading_array.should == [ :another_setting ]
|
495
|
+
cascading_composite_array.should == [ :another_setting ]
|
496
|
+
# inheriting class
|
497
|
+
class CascadingConfiguration::CascadingCompositeArray::Mock11sub1 < CascadingConfiguration::CascadingCompositeArray::Mock11
|
498
|
+
end
|
499
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock11sub1
|
500
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
501
|
+
cascading_composite_array.local_cascading_array.should == []
|
502
|
+
cascading_composite_array.clear
|
503
|
+
cascading_composite_array.should == []
|
504
|
+
cascading_composite_array += :yet_another_setting
|
505
|
+
cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
|
506
|
+
cascading_composite_array.should == [ :yet_another_setting ]
|
507
|
+
# instance
|
508
|
+
working_instance = CascadingConfiguration::CascadingCompositeArray::Mock11sub1.new
|
509
|
+
cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
|
510
|
+
cascading_composite_array.local_cascading_array.should == []
|
511
|
+
cascading_composite_array.should == [ :yet_another_setting ]
|
512
|
+
cascading_composite_array.clear
|
513
|
+
cascading_composite_array.should == []
|
514
|
+
cascading_composite_array += :and_still_another_setting
|
515
|
+
cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
|
516
|
+
cascading_composite_array.should == [ :and_still_another_setting ]
|
517
|
+
end
|
518
|
+
|
519
|
+
end
|