cascading-configuration-array-unique 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +225 -0
- data/README.rdoc +58 -0
- data/lib/cascading-configuration-array-unique.rb +28 -0
- data/lib/cascading-configuration-array-unique/CascadingConfiguration/Array/Unique.rb +12 -0
- data/lib/cascading-configuration-array-unique/CascadingConfiguration/Array/Unique/Interface.rb +107 -0
- data/lib/cascading-configuration-array-unique/_private_/CascadingConfiguration/Array/Unique/CompositingArray.rb +166 -0
- data/lib/cascading-configuration-array-unique/_private_/CascadingConfiguration/Array/Unique/Interface/GettersSetters.rb +220 -0
- data/lib/cascading-configuration-array-unique/_private_/CascadingConfiguration/Array/Unique/ModuleSupportMethods.rb +45 -0
- data/spec/CascadingConfiguration/Array/Unique_spec.rb +752 -0
- data/spec/_private_/CascadingConfiguration/Array/CompositingArray_spec.rb +1019 -0
- metadata +87 -0
@@ -0,0 +1,220 @@
|
|
1
|
+
|
2
|
+
module ::CascadingConfiguration::Array::Unique::Interface::GettersSetters
|
3
|
+
|
4
|
+
##########################################
|
5
|
+
# define_cascading_unique_array_setter #
|
6
|
+
##########################################
|
7
|
+
|
8
|
+
def define_cascading_unique_array_setter( configuration_name )
|
9
|
+
|
10
|
+
configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
|
11
|
+
|
12
|
+
array_setter_proc = Proc.new do |array|
|
13
|
+
|
14
|
+
return ::CascadingConfiguration::Array::Unique.
|
15
|
+
set_composite_unique_array( self,
|
16
|
+
configuration_name,
|
17
|
+
array )
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
::CascadingConfiguration::Variable.define_module_method( self,
|
22
|
+
configuration_setter_name,
|
23
|
+
& array_setter_proc )
|
24
|
+
::CascadingConfiguration::Variable.
|
25
|
+
define_instance_method_if_support_exists( self,
|
26
|
+
configuration_setter_name,
|
27
|
+
& array_setter_proc )
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
##########################################
|
32
|
+
# define_cascading_unique_array_getter #
|
33
|
+
##########################################
|
34
|
+
|
35
|
+
def define_cascading_unique_array_getter( configuration_name )
|
36
|
+
|
37
|
+
configuration_getter_name = configuration_name
|
38
|
+
|
39
|
+
array_getter_proc = Proc.new do
|
40
|
+
|
41
|
+
return ::CascadingConfiguration::Array::Unique.composite_unique_array( self,
|
42
|
+
configuration_name )
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
::CascadingConfiguration::Variable.define_module_method( self,
|
47
|
+
configuration_getter_name,
|
48
|
+
& array_getter_proc )
|
49
|
+
::CascadingConfiguration::Variable.
|
50
|
+
define_instance_method_if_support_exists( self,
|
51
|
+
configuration_getter_name,
|
52
|
+
& array_getter_proc )
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
####################################################
|
57
|
+
# define_class_configuration_unique_array_setter #
|
58
|
+
####################################################
|
59
|
+
|
60
|
+
def define_class_configuration_unique_array_setter( configuration_name )
|
61
|
+
|
62
|
+
configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
|
63
|
+
|
64
|
+
::CascadingConfiguration::Variable.define_module_method( self,
|
65
|
+
configuration_setter_name ) do |array|
|
66
|
+
|
67
|
+
return ::CascadingConfiguration::Array::Unique.
|
68
|
+
set_composite_unique_array( self,
|
69
|
+
configuration_name,
|
70
|
+
array )
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
####################################################
|
77
|
+
# define_class_configuration_unique_array_getter #
|
78
|
+
####################################################
|
79
|
+
|
80
|
+
def define_class_configuration_unique_array_getter( configuration_name )
|
81
|
+
|
82
|
+
configuration_getter_name = configuration_name
|
83
|
+
|
84
|
+
::CascadingConfiguration::Variable.define_module_method( self, configuration_getter_name ) do
|
85
|
+
|
86
|
+
return ::CascadingConfiguration::Array::Unique.composite_unique_array( self,
|
87
|
+
configuration_name )
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
####################################################
|
94
|
+
# define_local_configuration_unique_array_setter #
|
95
|
+
####################################################
|
96
|
+
|
97
|
+
def define_local_configuration_unique_array_setter( configuration_name )
|
98
|
+
|
99
|
+
configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
|
100
|
+
|
101
|
+
local_setter_proc = Proc.new do |array|
|
102
|
+
|
103
|
+
return ::CascadingConfiguration::Array::Unique.
|
104
|
+
set_composite_unique_array( self,
|
105
|
+
configuration_name,
|
106
|
+
array )
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
::CascadingConfiguration::Variable.define_local_instance_method( self,
|
111
|
+
configuration_setter_name,
|
112
|
+
& local_setter_proc )
|
113
|
+
::CascadingConfiguration::Variable.
|
114
|
+
define_instance_method_if_support_exists( self,
|
115
|
+
configuration_setter_name,
|
116
|
+
& local_setter_proc )
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
####################################################
|
121
|
+
# define_local_configuration_unique_array_getter #
|
122
|
+
####################################################
|
123
|
+
|
124
|
+
def define_local_configuration_unique_array_getter( configuration_name )
|
125
|
+
|
126
|
+
configuration_getter_name = configuration_name
|
127
|
+
|
128
|
+
local_getter_proc = Proc.new do
|
129
|
+
|
130
|
+
return ::CascadingConfiguration::Array::Unique.composite_unique_array( self,
|
131
|
+
configuration_name )
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
::CascadingConfiguration::Variable.define_local_instance_method( self,
|
136
|
+
configuration_getter_name,
|
137
|
+
& local_getter_proc )
|
138
|
+
::CascadingConfiguration::Variable.
|
139
|
+
define_instance_method_if_support_exists( self,
|
140
|
+
configuration_getter_name,
|
141
|
+
& local_getter_proc )
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
#######################################################
|
146
|
+
# define_instance_configuration_unique_array_setter #
|
147
|
+
#######################################################
|
148
|
+
|
149
|
+
def define_instance_configuration_unique_array_setter( configuration_name )
|
150
|
+
|
151
|
+
configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
|
152
|
+
|
153
|
+
::CascadingConfiguration::Variable.
|
154
|
+
define_instance_method( self, configuration_setter_name ) do |array|
|
155
|
+
|
156
|
+
return ::CascadingConfiguration::Array::Unique.
|
157
|
+
set_composite_unique_array( self,
|
158
|
+
configuration_name,
|
159
|
+
array )
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
#######################################################
|
166
|
+
# define_instance_configuration_unique_array_getter #
|
167
|
+
#######################################################
|
168
|
+
|
169
|
+
def define_instance_configuration_unique_array_getter( configuration_name )
|
170
|
+
|
171
|
+
configuration_getter_name = configuration_name
|
172
|
+
|
173
|
+
::CascadingConfiguration::Variable.define_instance_method( self, configuration_getter_name ) do
|
174
|
+
|
175
|
+
return ::CascadingConfiguration::Array::Unique.composite_unique_array( self,
|
176
|
+
configuration_name )
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
#####################################################
|
183
|
+
# define_object_configuration_unique_array_setter #
|
184
|
+
#####################################################
|
185
|
+
|
186
|
+
def define_object_configuration_unique_array_setter( configuration_name )
|
187
|
+
|
188
|
+
configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
|
189
|
+
|
190
|
+
::CascadingConfiguration::Variable.
|
191
|
+
define_local_instance_method( self, configuration_setter_name ) do |array|
|
192
|
+
|
193
|
+
return ::CascadingConfiguration::Array::Unique.
|
194
|
+
set_composite_unique_array( self,
|
195
|
+
configuration_name,
|
196
|
+
array )
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
201
|
+
|
202
|
+
#####################################################
|
203
|
+
# define_object_configuration_unique_array_getter #
|
204
|
+
#####################################################
|
205
|
+
|
206
|
+
def define_object_configuration_unique_array_getter( configuration_name )
|
207
|
+
|
208
|
+
configuration_getter_name = configuration_name
|
209
|
+
|
210
|
+
::CascadingConfiguration::Variable.define_local_instance_method( self,
|
211
|
+
configuration_getter_name ) do
|
212
|
+
|
213
|
+
return ::CascadingConfiguration::Array::Unique.composite_unique_array( self,
|
214
|
+
configuration_name )
|
215
|
+
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
module ::CascadingConfiguration::Array::Unique::ModuleSupportMethods
|
3
|
+
|
4
|
+
############################
|
5
|
+
# composite_unique_array #
|
6
|
+
############################
|
7
|
+
|
8
|
+
def composite_unique_array( configuration_instance, configuration_name )
|
9
|
+
|
10
|
+
composite_unique_array = nil
|
11
|
+
|
12
|
+
if ::CascadingConfiguration::Variable.has_configuration_variable?( configuration_instance,
|
13
|
+
configuration_name )
|
14
|
+
composite_unique_array = ::CascadingConfiguration::Variable.
|
15
|
+
get_configuration_variable( configuration_instance,
|
16
|
+
configuration_name )
|
17
|
+
else
|
18
|
+
composite_unique_array = ::CascadingConfiguration::Array::Unique::CompositingArray.
|
19
|
+
new( configuration_instance, configuration_name )
|
20
|
+
end
|
21
|
+
|
22
|
+
return composite_unique_array
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
################################
|
27
|
+
# set_composite_unique_array #
|
28
|
+
################################
|
29
|
+
|
30
|
+
def set_composite_unique_array( configuration_instance, configuration_name, array )
|
31
|
+
|
32
|
+
composite_unique_array = composite_unique_array( configuration_instance, configuration_name )
|
33
|
+
|
34
|
+
# we want the array to supplant existing config
|
35
|
+
# clear the array (excludes everything explicitly)
|
36
|
+
composite_unique_array.clear
|
37
|
+
|
38
|
+
# push array elements (removes anything excluded from exclude)
|
39
|
+
composite_unique_array.push( *array )
|
40
|
+
|
41
|
+
return composite_unique_array
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,752 @@
|
|
1
|
+
|
2
|
+
if $__cascading_configuration__spec__development
|
3
|
+
require_relative '../../../lib/cascading-configuration-array-unique.rb'
|
4
|
+
else
|
5
|
+
require 'cascading-configuration-array-unique'
|
6
|
+
end
|
7
|
+
|
8
|
+
describe CascadingConfiguration::Array::Unique do
|
9
|
+
|
10
|
+
#####################################
|
11
|
+
# attr_configuration_unique_array #
|
12
|
+
#####################################
|
13
|
+
|
14
|
+
it 'can define a configuration array, which is the primary interface' do
|
15
|
+
|
16
|
+
# possibilities:
|
17
|
+
# * module extended with setting
|
18
|
+
# => singleton gets attr_configuration and configurations
|
19
|
+
# => including modules and classes get nothing
|
20
|
+
# => extending modules and classes get nothing
|
21
|
+
# => instances of including and extending classes get nothing
|
22
|
+
# * module included with setting
|
23
|
+
# => singleton gets attr_configuration and configurations
|
24
|
+
# => including modules and classes get attr_configuration and configurations
|
25
|
+
# => instances of including classes get configurations
|
26
|
+
# => extending modules and classes get attr_configuration and configurations
|
27
|
+
# => instances of extending classes get nothing
|
28
|
+
module CascadingConfiguration::Array::Unique::ConfigurationMockModuleExtended
|
29
|
+
extend CascadingConfiguration::Array::Unique
|
30
|
+
# => singleton gets attr_configuration and configurations
|
31
|
+
respond_to?( :attr_configuration_unique_array ).should == true
|
32
|
+
attr_configuration_unique_array :configuration_setting
|
33
|
+
respond_to?( :configuration_setting ).should == true
|
34
|
+
configuration_setting.should == []
|
35
|
+
configuration_setting.push( :a_configuration )
|
36
|
+
configuration_setting.should == [ :a_configuration ]
|
37
|
+
instance_methods.include?( :configuration_setting ).should == false
|
38
|
+
instance_variables.empty?.should == true
|
39
|
+
# => including modules and classes get nothing
|
40
|
+
module SubmoduleIncluding
|
41
|
+
include CascadingConfiguration::Array::Unique::ConfigurationMockModuleExtended
|
42
|
+
instance_methods.include?( :configuration_setting ).should == false
|
43
|
+
respond_to?( :configuration_setting ).should == false
|
44
|
+
instance_variables.empty?.should == true
|
45
|
+
end
|
46
|
+
# => extending modules and classes get nothing
|
47
|
+
module SubmoduleExtending
|
48
|
+
extend CascadingConfiguration::Array::Unique::ConfigurationMockModuleExtended
|
49
|
+
instance_methods.include?( :configuration_setting ).should == false
|
50
|
+
respond_to?( :configuration_setting ).should == false
|
51
|
+
instance_variables.empty?.should == true
|
52
|
+
end
|
53
|
+
# => instances of including and extending classes get nothing
|
54
|
+
class ClassIncluding
|
55
|
+
include CascadingConfiguration::Array::Unique::ConfigurationMockModuleExtended
|
56
|
+
instance_methods.include?( :configuration_setting ).should == false
|
57
|
+
respond_to?( :configuration_setting ).should == false
|
58
|
+
instance_variables.empty?.should == true
|
59
|
+
end
|
60
|
+
class ClassExtending
|
61
|
+
extend CascadingConfiguration::Array::Unique::ConfigurationMockModuleExtended
|
62
|
+
instance_methods.include?( :configuration_setting ).should == false
|
63
|
+
respond_to?( :configuration_setting ).should == false
|
64
|
+
instance_variables.empty?.should == true
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# * module included with setting
|
69
|
+
module CascadingConfiguration::Array::Unique::ConfigurationMockModuleIncluded
|
70
|
+
include CascadingConfiguration::Array::Unique
|
71
|
+
# => singleton gets attr_configuration and configurations
|
72
|
+
respond_to?( :attr_configuration_unique_array ).should == true
|
73
|
+
attr_configuration_unique_array :configuration_setting
|
74
|
+
respond_to?( :configuration_setting ).should == true
|
75
|
+
configuration_setting.should == []
|
76
|
+
configuration_setting.push( :a_configuration )
|
77
|
+
configuration_setting.should == [ :a_configuration ]
|
78
|
+
instance_methods.include?( :configuration_setting ).should == true
|
79
|
+
instance_variables.empty?.should == true
|
80
|
+
# => including modules and classes get attr_configuration and configurations
|
81
|
+
module SubmoduleIncluding
|
82
|
+
include CascadingConfiguration::Array::Unique::ConfigurationMockModuleIncluded
|
83
|
+
instance_methods.include?( :configuration_setting ).should == true
|
84
|
+
respond_to?( :configuration_setting ).should == true
|
85
|
+
configuration_setting.should == [ :a_configuration ]
|
86
|
+
configuration_setting.push( :another_configuration )
|
87
|
+
configuration_setting.push( :another_configuration )
|
88
|
+
configuration_setting.should == [ :a_configuration, :another_configuration ]
|
89
|
+
instance_variables.empty?.should == true
|
90
|
+
end
|
91
|
+
# => extending modules and classes get attr_configuration and configurations
|
92
|
+
module SubmoduleExtending
|
93
|
+
extend CascadingConfiguration::Array::Unique::ConfigurationMockModuleIncluded
|
94
|
+
# if we're extended then we want to use the eigenclass ancestor chain
|
95
|
+
# - the first ancestor will be the extending module
|
96
|
+
# - the rest of the ancestors will be the extending module's include chain
|
97
|
+
respond_to?( :configuration_setting ).should == true
|
98
|
+
configuration_setting.should == [ :a_configuration ]
|
99
|
+
configuration_setting.push( :some_other_configuration )
|
100
|
+
configuration_setting.push( :some_other_configuration )
|
101
|
+
configuration_setting.push( :some_other_configuration )
|
102
|
+
configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
103
|
+
instance_methods.include?( :configuration_setting ).should == false
|
104
|
+
instance_variables.empty?.should == true
|
105
|
+
end
|
106
|
+
# => instances of including classes get configurations
|
107
|
+
class ClassIncluding
|
108
|
+
include CascadingConfiguration::Array::Unique::ConfigurationMockModuleIncluded
|
109
|
+
instance_methods.include?( :configuration_setting ).should == true
|
110
|
+
respond_to?( :configuration_setting ).should == true
|
111
|
+
configuration_setting.should == [ :a_configuration ]
|
112
|
+
configuration_setting.push( :some_other_configuration )
|
113
|
+
configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
114
|
+
instance_variables.empty?.should == true
|
115
|
+
end
|
116
|
+
setting_class_including_instance = ClassIncluding.new
|
117
|
+
setting_class_including_instance.respond_to?( :configuration_setting ).should == true
|
118
|
+
setting_class_including_instance.configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
119
|
+
setting_class_including_instance.configuration_setting.delete( :some_other_configuration )
|
120
|
+
setting_class_including_instance.configuration_setting = [ :our_setting_value ]
|
121
|
+
setting_class_including_instance.configuration_setting.should == [ :our_setting_value ]
|
122
|
+
setting_class_including_instance.instance_variables.empty?.should == true
|
123
|
+
# => instances of extending classes get nothing
|
124
|
+
class ClassExtending
|
125
|
+
extend CascadingConfiguration::Array::Unique::ConfigurationMockModuleIncluded
|
126
|
+
respond_to?( :configuration_setting ).should == true
|
127
|
+
configuration_setting.should == [ :a_configuration ]
|
128
|
+
configuration_setting.push( :some_other_configuration )
|
129
|
+
configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
130
|
+
instance_variables.empty?.should == true
|
131
|
+
end
|
132
|
+
setting_class_including_instance = ClassExtending.new
|
133
|
+
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
134
|
+
setting_class_including_instance.instance_variables.empty?.should == true
|
135
|
+
end
|
136
|
+
|
137
|
+
class CascadingConfiguration::Array::Unique::ConfigurationMockClass
|
138
|
+
include CascadingConfiguration::Array::Unique::ConfigurationMockModuleIncluded::SubmoduleIncluding
|
139
|
+
configuration_setting.should == [ :a_configuration, :another_configuration ]
|
140
|
+
configuration_setting.push( :some_other_configuration )
|
141
|
+
configuration_setting.push( :some_other_configuration )
|
142
|
+
configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
143
|
+
instance_variables.empty?.should == true
|
144
|
+
end
|
145
|
+
object_instance_one = CascadingConfiguration::Array::Unique::ConfigurationMockClass.new
|
146
|
+
object_instance_one.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
147
|
+
object_instance_one.configuration_setting.delete( :a_configuration )
|
148
|
+
object_instance_one.configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
149
|
+
object_instance_one.instance_variables.empty?.should == true
|
150
|
+
class CascadingConfiguration::Array::Unique::ConfigurationMockClassSub1 < CascadingConfiguration::Array::Unique::ConfigurationMockClass
|
151
|
+
configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
152
|
+
configuration_setting.delete( :a_configuration )
|
153
|
+
configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
154
|
+
instance_variables.empty?.should == true
|
155
|
+
end
|
156
|
+
object_instance_two = CascadingConfiguration::Array::Unique::ConfigurationMockClassSub1.new
|
157
|
+
object_instance_two.configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
158
|
+
object_instance_two.configuration_setting.delete( :another_configuration )
|
159
|
+
object_instance_two.configuration_setting.should == [ :some_other_configuration ]
|
160
|
+
object_instance_two.instance_variables.empty?.should == true
|
161
|
+
class CascadingConfiguration::Array::Unique::ConfigurationMockClassSub2 < CascadingConfiguration::Array::Unique::ConfigurationMockClassSub1
|
162
|
+
configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
163
|
+
#configuration_setting.push( :yet_another_configuration )
|
164
|
+
#configuration_setting.should == [ :another_configuration, :some_other_configuration, :yet_another_configuration ]
|
165
|
+
instance_variables.empty?.should == true
|
166
|
+
end
|
167
|
+
|
168
|
+
# change ancestor setting
|
169
|
+
CascadingConfiguration::Array::Unique::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
170
|
+
CascadingConfiguration::Array::Unique::ConfigurationMockClass.configuration_setting.push( :a_yet_unused_configuration )
|
171
|
+
CascadingConfiguration::Array::Unique::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
172
|
+
object_instance_one.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
173
|
+
CascadingConfiguration::Array::Unique::ConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
174
|
+
object_instance_two.configuration_setting.should == [ :some_other_configuration, :a_yet_unused_configuration ]
|
175
|
+
|
176
|
+
# freeze ancestor setting
|
177
|
+
object_instance_one.configuration_setting.freeze!
|
178
|
+
object_instance_one.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
179
|
+
CascadingConfiguration::Array::Unique::ConfigurationMockClassSub1.configuration_setting.freeze!
|
180
|
+
CascadingConfiguration::Array::Unique::ConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
181
|
+
CascadingConfiguration::Array::Unique::ConfigurationMockClass.configuration_setting.push( :non_cascading_configuration )
|
182
|
+
CascadingConfiguration::Array::Unique::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration, :a_yet_unused_configuration, :non_cascading_configuration ]
|
183
|
+
object_instance_one.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
184
|
+
CascadingConfiguration::Array::Unique::ConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
185
|
+
object_instance_two.configuration_setting.should == [ :some_other_configuration, :a_yet_unused_configuration ]
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
############################################
|
190
|
+
# attr_module_configuration_unique_array #
|
191
|
+
# attr_class_configuration_unique_array #
|
192
|
+
############################################
|
193
|
+
|
194
|
+
it 'can define a class configuration array, which will not cascade to instances' do
|
195
|
+
|
196
|
+
# possibilities:
|
197
|
+
# * module extended with setting
|
198
|
+
# => singleton gets attr_configuration and configurations
|
199
|
+
# => including modules and classes get nothing
|
200
|
+
# => extending modules and classes get nothing
|
201
|
+
# => instances of including and extending classes get nothing
|
202
|
+
# * module included with setting
|
203
|
+
# => singleton gets attr_configuration and configurations
|
204
|
+
# => including modules and classes get attr_configuration and configurations
|
205
|
+
# => instances of including classes get configurations
|
206
|
+
# => extending modules and classes get attr_configuration and configurations
|
207
|
+
# => instances of extending classes get nothing
|
208
|
+
module CascadingConfiguration::Array::Unique::ClassConfigurationMockModuleExtended
|
209
|
+
extend CascadingConfiguration::Array::Unique
|
210
|
+
# => singleton gets attr_configuration and configurations
|
211
|
+
respond_to?( :attr_module_configuration_unique_array ).should == true
|
212
|
+
method( :attr_module_configuration_unique_array ).should == method( :attr_class_configuration_unique_array )
|
213
|
+
attr_module_configuration_unique_array :configuration_setting
|
214
|
+
respond_to?( :configuration_setting ).should == true
|
215
|
+
configuration_setting.should == []
|
216
|
+
configuration_setting.push( :a_configuration )
|
217
|
+
configuration_setting.should == [ :a_configuration ]
|
218
|
+
instance_methods.include?( :configuration_setting ).should == false
|
219
|
+
instance_variables.empty?.should == true
|
220
|
+
# => including modules and classes get nothing
|
221
|
+
module SubmoduleIncluding
|
222
|
+
include CascadingConfiguration::Array::Unique::ClassConfigurationMockModuleExtended
|
223
|
+
instance_methods.include?( :configuration_setting ).should == false
|
224
|
+
respond_to?( :configuration_setting ).should == false
|
225
|
+
instance_variables.empty?.should == true
|
226
|
+
end
|
227
|
+
# => extending modules and classes get nothing
|
228
|
+
module SubmoduleExtending
|
229
|
+
extend CascadingConfiguration::Array::Unique::ClassConfigurationMockModuleExtended
|
230
|
+
instance_methods.include?( :configuration_setting ).should == false
|
231
|
+
respond_to?( :configuration_setting ).should == false
|
232
|
+
instance_variables.empty?.should == true
|
233
|
+
end
|
234
|
+
# => instances of including and extending classes get nothing
|
235
|
+
class ClassIncluding
|
236
|
+
include CascadingConfiguration::Array::Unique::ClassConfigurationMockModuleExtended
|
237
|
+
instance_methods.include?( :configuration_setting ).should == false
|
238
|
+
respond_to?( :configuration_setting ).should == false
|
239
|
+
instance_variables.empty?.should == true
|
240
|
+
end
|
241
|
+
class ClassExtending
|
242
|
+
extend CascadingConfiguration::Array::Unique::ClassConfigurationMockModuleExtended
|
243
|
+
instance_methods.include?( :configuration_setting ).should == false
|
244
|
+
respond_to?( :configuration_setting ).should == false
|
245
|
+
instance_variables.empty?.should == true
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
# * module included with setting
|
250
|
+
module CascadingConfiguration::Array::Unique::ClassConfigurationMockModuleIncluded
|
251
|
+
include CascadingConfiguration::Array::Unique
|
252
|
+
# => singleton gets attr_configuration and configurations
|
253
|
+
respond_to?( :attr_module_configuration_unique_array ).should == true
|
254
|
+
attr_module_configuration_unique_array :configuration_setting
|
255
|
+
respond_to?( :configuration_setting ).should == true
|
256
|
+
configuration_setting.should == []
|
257
|
+
configuration_setting.push( :a_configuration )
|
258
|
+
configuration_setting.should == [ :a_configuration ]
|
259
|
+
instance_methods.include?( :configuration_setting ).should == false
|
260
|
+
instance_variables.empty?.should == true
|
261
|
+
# => including modules and classes get attr_configuration and configurations
|
262
|
+
module SubmoduleIncluding
|
263
|
+
include CascadingConfiguration::Array::Unique::ClassConfigurationMockModuleIncluded
|
264
|
+
instance_methods.include?( :configuration_setting ).should == false
|
265
|
+
respond_to?( :configuration_setting ).should == true
|
266
|
+
configuration_setting.should == [ :a_configuration ]
|
267
|
+
configuration_setting.push( :another_configuration )
|
268
|
+
configuration_setting.should == [ :a_configuration, :another_configuration ]
|
269
|
+
instance_methods.include?( :configuration_setting ).should == false
|
270
|
+
instance_variables.empty?.should == true
|
271
|
+
end
|
272
|
+
# => extending modules and classes get attr_configuration and configurations
|
273
|
+
module SubmoduleExtending
|
274
|
+
extend CascadingConfiguration::Array::Unique::ClassConfigurationMockModuleIncluded
|
275
|
+
# if we're extended then we want to use the eigenclass ancestor chain
|
276
|
+
# - the first ancestor will be the extending module
|
277
|
+
# - the rest of the ancestors will be the extending module's include chain
|
278
|
+
respond_to?( :configuration_setting ).should == true
|
279
|
+
configuration_setting.should == [ :a_configuration ]
|
280
|
+
configuration_setting.push( :some_other_configuration )
|
281
|
+
configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
282
|
+
instance_methods.include?( :configuration_setting ).should == false
|
283
|
+
instance_variables.empty?.should == true
|
284
|
+
end
|
285
|
+
# => instances of including classes get configurations
|
286
|
+
class ClassIncluding
|
287
|
+
include CascadingConfiguration::Array::Unique::ClassConfigurationMockModuleIncluded
|
288
|
+
instance_methods.include?( :configuration_setting ).should == false
|
289
|
+
respond_to?( :configuration_setting ).should == true
|
290
|
+
configuration_setting.should == [ :a_configuration ]
|
291
|
+
configuration_setting.push( :some_other_configuration )
|
292
|
+
configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
293
|
+
instance_variables.empty?.should == true
|
294
|
+
end
|
295
|
+
setting_class_including_instance = ClassIncluding.new
|
296
|
+
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
297
|
+
setting_class_including_instance.instance_variables.empty?.should == true
|
298
|
+
# => instances of extending classes get nothing
|
299
|
+
class ClassExtending
|
300
|
+
extend CascadingConfiguration::Array::Unique::ClassConfigurationMockModuleIncluded
|
301
|
+
instance_methods.include?( :configuration_setting ).should == false
|
302
|
+
respond_to?( :configuration_setting ).should == true
|
303
|
+
configuration_setting.should == [ :a_configuration ]
|
304
|
+
configuration_setting.push( :some_other_configuration )
|
305
|
+
configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
306
|
+
instance_variables.empty?.should == true
|
307
|
+
end
|
308
|
+
setting_class_including_instance = ClassExtending.new
|
309
|
+
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
310
|
+
setting_class_including_instance.instance_variables.empty?.should == true
|
311
|
+
end
|
312
|
+
|
313
|
+
class CascadingConfiguration::Array::Unique::ClassConfigurationMockClass
|
314
|
+
include CascadingConfiguration::Array::Unique::ClassConfigurationMockModuleIncluded::SubmoduleIncluding
|
315
|
+
instance_methods.include?( :configuration_setting ).should == false
|
316
|
+
configuration_setting.should == [ :a_configuration, :another_configuration ]
|
317
|
+
configuration_setting.push( :some_other_configuration )
|
318
|
+
configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
319
|
+
instance_variables.empty?.should == true
|
320
|
+
end
|
321
|
+
object_instance_one = CascadingConfiguration::Array::Unique::ClassConfigurationMockClass.new
|
322
|
+
object_instance_one.respond_to?( :configuration_setting ).should == false
|
323
|
+
object_instance_one.instance_variables.empty?.should == true
|
324
|
+
class CascadingConfiguration::Array::Unique::ClassConfigurationMockClassSub1 < CascadingConfiguration::Array::Unique::ClassConfigurationMockClass
|
325
|
+
instance_methods.include?( :configuration_setting ).should == false
|
326
|
+
configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
327
|
+
configuration_setting.delete( :a_configuration )
|
328
|
+
configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
329
|
+
instance_variables.empty?.should == true
|
330
|
+
end
|
331
|
+
object_instance_two = CascadingConfiguration::Array::Unique::ClassConfigurationMockClassSub1.new
|
332
|
+
object_instance_two.respond_to?( :configuration_setting ).should == false
|
333
|
+
object_instance_two.instance_variables.empty?.should == true
|
334
|
+
class CascadingConfiguration::Array::Unique::ClassConfigurationMockClassSub2 < CascadingConfiguration::Array::Unique::ClassConfigurationMockClassSub1
|
335
|
+
instance_methods.include?( :configuration_setting ).should == false
|
336
|
+
configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
337
|
+
configuration_setting.push( :yet_another_configuration )
|
338
|
+
configuration_setting.should == [ :another_configuration, :some_other_configuration, :yet_another_configuration ]
|
339
|
+
instance_variables.empty?.should == true
|
340
|
+
end
|
341
|
+
|
342
|
+
# change ancestor setting
|
343
|
+
CascadingConfiguration::Array::Unique::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
344
|
+
CascadingConfiguration::Array::Unique::ClassConfigurationMockClass.configuration_setting.push( :a_yet_unused_configuration )
|
345
|
+
CascadingConfiguration::Array::Unique::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
346
|
+
CascadingConfiguration::Array::Unique::ClassConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
347
|
+
|
348
|
+
# freeze ancestor setting
|
349
|
+
CascadingConfiguration::Array::Unique::ClassConfigurationMockClassSub1.configuration_setting.freeze!
|
350
|
+
CascadingConfiguration::Array::Unique::ClassConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
351
|
+
CascadingConfiguration::Array::Unique::ClassConfigurationMockClass.configuration_setting.push( :non_cascading_configuration )
|
352
|
+
CascadingConfiguration::Array::Unique::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration, :a_yet_unused_configuration, :non_cascading_configuration ]
|
353
|
+
CascadingConfiguration::Array::Unique::ClassConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
354
|
+
|
355
|
+
end
|
356
|
+
|
357
|
+
###########################################
|
358
|
+
# attr_local_configuration_unique_array #
|
359
|
+
###########################################
|
360
|
+
|
361
|
+
it 'can define a local configuration array, which will not cascade' do
|
362
|
+
|
363
|
+
# possibilities:
|
364
|
+
# * module extended with setting
|
365
|
+
# => singleton gets attr_configuration and configurations
|
366
|
+
# => including modules and classes get nothing
|
367
|
+
# => extending modules and classes get nothing
|
368
|
+
# => instances of including and extending classes get nothing
|
369
|
+
# * module included with setting
|
370
|
+
# => singleton gets attr_configuration and configurations
|
371
|
+
# => including modules and classes get attr_configuration and configurations
|
372
|
+
# => instances of including classes get configurations
|
373
|
+
# => extending modules and classes get attr_configuration and configurations
|
374
|
+
# => instances of extending classes get nothing
|
375
|
+
module CascadingConfiguration::Array::Unique::LocalConfigurationMockModuleExtended
|
376
|
+
extend CascadingConfiguration::Array::Unique
|
377
|
+
# => singleton gets attr_configuration and configurations
|
378
|
+
respond_to?( :attr_local_configuration_unique_array ).should == true
|
379
|
+
attr_local_configuration_unique_array :configuration_setting
|
380
|
+
respond_to?( :configuration_setting ).should == true
|
381
|
+
configuration_setting.should == []
|
382
|
+
configuration_setting.push( :a_configuration )
|
383
|
+
configuration_setting.should == [ :a_configuration ]
|
384
|
+
instance_methods.include?( :configuration_setting ).should == false
|
385
|
+
instance_variables.empty?.should == true
|
386
|
+
# => including modules and classes get nothing
|
387
|
+
module SubmoduleIncluding
|
388
|
+
include CascadingConfiguration::Array::Unique::LocalConfigurationMockModuleExtended
|
389
|
+
instance_methods.include?( :configuration_setting ).should == false
|
390
|
+
respond_to?( :configuration_setting ).should == false
|
391
|
+
instance_variables.empty?.should == true
|
392
|
+
end
|
393
|
+
# => extending modules and classes get nothing
|
394
|
+
module SubmoduleExtending
|
395
|
+
extend CascadingConfiguration::Array::Unique::LocalConfigurationMockModuleExtended
|
396
|
+
instance_methods.include?( :configuration_setting ).should == false
|
397
|
+
respond_to?( :configuration_setting ).should == false
|
398
|
+
instance_variables.empty?.should == true
|
399
|
+
end
|
400
|
+
# => instances of including and extending classes get nothing
|
401
|
+
class ClassIncluding
|
402
|
+
include CascadingConfiguration::Array::Unique::LocalConfigurationMockModuleExtended
|
403
|
+
instance_methods.include?( :configuration_setting ).should == false
|
404
|
+
respond_to?( :configuration_setting ).should == false
|
405
|
+
instance_variables.empty?.should == true
|
406
|
+
end
|
407
|
+
class ClassExtending
|
408
|
+
extend CascadingConfiguration::Array::Unique::LocalConfigurationMockModuleExtended
|
409
|
+
instance_methods.include?( :configuration_setting ).should == false
|
410
|
+
respond_to?( :configuration_setting ).should == false
|
411
|
+
instance_variables.empty?.should == true
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
415
|
+
# * module included with setting
|
416
|
+
module CascadingConfiguration::Array::Unique::LocalConfigurationMockModuleIncluded
|
417
|
+
include CascadingConfiguration::Array::Unique
|
418
|
+
# => singleton gets attr_configuration and configurations
|
419
|
+
respond_to?( :attr_local_configuration_unique_array ).should == true
|
420
|
+
attr_local_configuration_unique_array :configuration_setting
|
421
|
+
respond_to?( :configuration_setting ).should == true
|
422
|
+
configuration_setting.should == []
|
423
|
+
configuration_setting.push( :a_configuration )
|
424
|
+
configuration_setting.should == [ :a_configuration ]
|
425
|
+
instance_methods.include?( :configuration_setting ).should == true
|
426
|
+
instance_variables.empty?.should == true
|
427
|
+
# => including modules and classes get attr_configuration and configurations
|
428
|
+
module SubmoduleIncluding
|
429
|
+
include CascadingConfiguration::Array::Unique::LocalConfigurationMockModuleIncluded
|
430
|
+
instance_methods.include?( :configuration_setting ).should == true
|
431
|
+
respond_to?( :configuration_setting ).should == false
|
432
|
+
instance_variables.empty?.should == true
|
433
|
+
end
|
434
|
+
# => extending modules and classes get attr_configuration and configurations
|
435
|
+
module SubmoduleExtending
|
436
|
+
extend CascadingConfiguration::Array::Unique::LocalConfigurationMockModuleIncluded
|
437
|
+
# if we're extended then we want to use the eigenclass ancestor chain
|
438
|
+
# - the first ancestor will be the extending module
|
439
|
+
# - the rest of the ancestors will be the extending module's include chain
|
440
|
+
respond_to?( :configuration_setting ).should == true
|
441
|
+
instance_methods.include?( :configuration_setting ).should == false
|
442
|
+
instance_variables.empty?.should == true
|
443
|
+
end
|
444
|
+
# => instances of including classes get configurations
|
445
|
+
class ClassIncluding
|
446
|
+
include CascadingConfiguration::Array::Unique::LocalConfigurationMockModuleIncluded
|
447
|
+
instance_methods.include?( :configuration_setting ).should == true
|
448
|
+
respond_to?( :configuration_setting ).should == false
|
449
|
+
instance_variables.empty?.should == true
|
450
|
+
end
|
451
|
+
setting_class_including_instance = ClassIncluding.new
|
452
|
+
setting_class_including_instance.respond_to?( :configuration_setting ).should == true
|
453
|
+
setting_class_including_instance.instance_variables.empty?.should == true
|
454
|
+
# => instances of extending classes get nothing
|
455
|
+
class ClassExtending
|
456
|
+
extend CascadingConfiguration::Array::Unique::LocalConfigurationMockModuleIncluded
|
457
|
+
instance_methods.include?( :configuration_setting ).should == false
|
458
|
+
respond_to?( :configuration_setting ).should == true
|
459
|
+
instance_variables.empty?.should == true
|
460
|
+
end
|
461
|
+
setting_class_including_instance = ClassExtending.new
|
462
|
+
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
463
|
+
setting_class_including_instance.instance_variables.empty?.should == true
|
464
|
+
end
|
465
|
+
|
466
|
+
class CascadingConfiguration::Array::Unique::LocalConfigurationMockClass
|
467
|
+
include CascadingConfiguration::Array::Unique::LocalConfigurationMockModuleIncluded::SubmoduleIncluding
|
468
|
+
instance_methods.include?( :configuration_setting ).should == true
|
469
|
+
respond_to?( :configuration_setting ).should == false
|
470
|
+
instance_variables.empty?.should == true
|
471
|
+
end
|
472
|
+
object_instance_one = CascadingConfiguration::Array::Unique::LocalConfigurationMockClass.new
|
473
|
+
object_instance_one.respond_to?( :configuration_setting ).should == true
|
474
|
+
object_instance_one.instance_variables.empty?.should == true
|
475
|
+
class CascadingConfiguration::Array::Unique::LocalConfigurationMockClassSub1 < CascadingConfiguration::Array::Unique::LocalConfigurationMockClass
|
476
|
+
instance_methods.include?( :configuration_setting ).should == true
|
477
|
+
respond_to?( :configuration_setting ).should == false
|
478
|
+
instance_variables.empty?.should == true
|
479
|
+
end
|
480
|
+
object_instance_two = CascadingConfiguration::Array::Unique::LocalConfigurationMockClassSub1.new
|
481
|
+
object_instance_two.respond_to?( :configuration_setting ).should == true
|
482
|
+
object_instance_two.instance_variables.empty?.should == true
|
483
|
+
class CascadingConfiguration::Array::Unique::LocalConfigurationMockClassSub2 < CascadingConfiguration::Array::Unique::LocalConfigurationMockClassSub1
|
484
|
+
instance_methods.include?( :configuration_setting ).should == true
|
485
|
+
respond_to?( :configuration_setting ).should == false
|
486
|
+
instance_variables.empty?.should == true
|
487
|
+
end
|
488
|
+
|
489
|
+
end
|
490
|
+
|
491
|
+
##############################################
|
492
|
+
# attr_instance_configuration_unique_array #
|
493
|
+
##############################################
|
494
|
+
|
495
|
+
it 'can define an instance configuration array, which will not cascade' do
|
496
|
+
|
497
|
+
# possibilities:
|
498
|
+
# * module extended with setting
|
499
|
+
# => singleton gets attr_configuration and configurations
|
500
|
+
# => including modules and classes get nothing
|
501
|
+
# => extending modules and classes get nothing
|
502
|
+
# => instances of including and extending classes get nothing
|
503
|
+
# * module included with setting
|
504
|
+
# => singleton gets attr_configuration and configurations
|
505
|
+
# => including modules and classes get attr_configuration and configurations
|
506
|
+
# => instances of including classes get configurations
|
507
|
+
# => extending modules and classes get attr_configuration and configurations
|
508
|
+
# => instances of extending classes get nothing
|
509
|
+
module CascadingConfiguration::Array::Unique::InstanceConfigurationMockModuleExtended
|
510
|
+
extend CascadingConfiguration::Array::Unique
|
511
|
+
# => singleton gets attr_configuration and configurations
|
512
|
+
instance_variables.empty?.should == true
|
513
|
+
# => including modules and classes get nothing
|
514
|
+
module SubmoduleIncluding
|
515
|
+
include CascadingConfiguration::Array::Unique::InstanceConfigurationMockModuleExtended
|
516
|
+
instance_methods.include?( :configuration_setting ).should == false
|
517
|
+
respond_to?( :configuration_setting ).should == false
|
518
|
+
instance_variables.empty?.should == true
|
519
|
+
end
|
520
|
+
# => extending modules and classes get nothing
|
521
|
+
module SubmoduleExtending
|
522
|
+
extend CascadingConfiguration::Array::Unique::InstanceConfigurationMockModuleExtended
|
523
|
+
instance_methods.include?( :configuration_setting ).should == false
|
524
|
+
respond_to?( :configuration_setting ).should == false
|
525
|
+
instance_variables.empty?.should == true
|
526
|
+
end
|
527
|
+
# => instances of including and extending classes get nothing
|
528
|
+
class ClassIncluding
|
529
|
+
include CascadingConfiguration::Array::Unique::InstanceConfigurationMockModuleExtended
|
530
|
+
instance_methods.include?( :configuration_setting ).should == false
|
531
|
+
respond_to?( :configuration_setting ).should == false
|
532
|
+
instance_variables.empty?.should == true
|
533
|
+
end
|
534
|
+
class ClassExtending
|
535
|
+
extend CascadingConfiguration::Array::Unique::InstanceConfigurationMockModuleExtended
|
536
|
+
instance_methods.include?( :configuration_setting ).should == false
|
537
|
+
respond_to?( :configuration_setting ).should == false
|
538
|
+
instance_variables.empty?.should == true
|
539
|
+
end
|
540
|
+
end
|
541
|
+
|
542
|
+
# * module included with setting
|
543
|
+
module CascadingConfiguration::Array::Unique::InstanceConfigurationMockModuleIncluded
|
544
|
+
include CascadingConfiguration::Array::Unique
|
545
|
+
# => singleton gets attr_configuration and configurations
|
546
|
+
respond_to?( :attr_instance_configuration_unique_array ).should == true
|
547
|
+
attr_instance_configuration_unique_array :configuration_setting
|
548
|
+
respond_to?( :configuration_setting ).should == false
|
549
|
+
instance_methods.include?( :configuration_setting ).should == true
|
550
|
+
instance_variables.empty?.should == true
|
551
|
+
# => including modules and classes get attr_configuration and configurations
|
552
|
+
module SubmoduleIncluding
|
553
|
+
include CascadingConfiguration::Array::Unique::InstanceConfigurationMockModuleIncluded
|
554
|
+
instance_methods.include?( :configuration_setting ).should == true
|
555
|
+
respond_to?( :configuration_setting ).should == false
|
556
|
+
instance_methods.include?( :configuration_setting ).should == true
|
557
|
+
instance_variables.empty?.should == true
|
558
|
+
end
|
559
|
+
# => extending modules and classes get attr_configuration and configurations
|
560
|
+
module SubmoduleExtending
|
561
|
+
extend CascadingConfiguration::Array::Unique::InstanceConfigurationMockModuleIncluded
|
562
|
+
# if we're extended then we want to use the eigenclass ancestor chain
|
563
|
+
# - the first ancestor will be the extending module
|
564
|
+
# - the rest of the ancestors will be the extending module's include chain
|
565
|
+
respond_to?( :configuration_setting ).should == true
|
566
|
+
instance_methods.include?( :configuration_setting ).should == false
|
567
|
+
instance_variables.empty?.should == true
|
568
|
+
end
|
569
|
+
# => instances of including classes get configurations
|
570
|
+
class ClassIncluding
|
571
|
+
include CascadingConfiguration::Array::Unique::InstanceConfigurationMockModuleIncluded
|
572
|
+
instance_methods.include?( :configuration_setting ).should == true
|
573
|
+
respond_to?( :configuration_setting ).should == false
|
574
|
+
instance_variables.empty?.should == true
|
575
|
+
end
|
576
|
+
setting_class_including_instance = ClassIncluding.new
|
577
|
+
setting_class_including_instance.respond_to?( :configuration_setting ).should == true
|
578
|
+
setting_class_including_instance.instance_variables.empty?.should == true
|
579
|
+
# => instances of extending classes get nothing
|
580
|
+
class ClassExtending
|
581
|
+
extend CascadingConfiguration::Array::Unique::InstanceConfigurationMockModuleIncluded
|
582
|
+
instance_methods.include?( :configuration_setting ).should == false
|
583
|
+
respond_to?( :configuration_setting ).should == true
|
584
|
+
instance_variables.empty?.should == true
|
585
|
+
end
|
586
|
+
setting_class_including_instance = ClassExtending.new
|
587
|
+
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
588
|
+
setting_class_including_instance.instance_variables.empty?.should == true
|
589
|
+
end
|
590
|
+
|
591
|
+
class CascadingConfiguration::Array::Unique::InstanceConfigurationMockClass
|
592
|
+
include CascadingConfiguration::Array::Unique::InstanceConfigurationMockModuleIncluded::SubmoduleIncluding
|
593
|
+
instance_methods.include?( :configuration_setting ).should == true
|
594
|
+
respond_to?( :configuration_setting ).should == false
|
595
|
+
instance_variables.empty?.should == true
|
596
|
+
end
|
597
|
+
object_instance_one = CascadingConfiguration::Array::Unique::InstanceConfigurationMockClass.new
|
598
|
+
object_instance_one.respond_to?( :configuration_setting ).should == true
|
599
|
+
object_instance_one.instance_variables.empty?.should == true
|
600
|
+
class CascadingConfiguration::Array::Unique::InstanceConfigurationMockClassSub1 < CascadingConfiguration::Array::Unique::InstanceConfigurationMockClass
|
601
|
+
instance_methods.include?( :configuration_setting ).should == true
|
602
|
+
respond_to?( :configuration_setting ).should == false
|
603
|
+
instance_variables.empty?.should == true
|
604
|
+
end
|
605
|
+
object_instance_two = CascadingConfiguration::Array::Unique::InstanceConfigurationMockClassSub1.new
|
606
|
+
object_instance_two.respond_to?( :configuration_setting ).should == true
|
607
|
+
object_instance_two.instance_variables.empty?.should == true
|
608
|
+
class CascadingConfiguration::Array::Unique::InstanceConfigurationMockClassSub2 < CascadingConfiguration::Array::Unique::InstanceConfigurationMockClassSub1
|
609
|
+
instance_methods.include?( :configuration_setting ).should == true
|
610
|
+
respond_to?( :configuration_setting ).should == false
|
611
|
+
instance_variables.empty?.should == true
|
612
|
+
end
|
613
|
+
|
614
|
+
end
|
615
|
+
|
616
|
+
|
617
|
+
############################################
|
618
|
+
# attr_object_configuration_unique_array #
|
619
|
+
############################################
|
620
|
+
|
621
|
+
it 'can define an object configuration array, which will not cascade' do
|
622
|
+
|
623
|
+
# possibilities:
|
624
|
+
# * module extended with setting
|
625
|
+
# => singleton gets attr_configuration and configurations
|
626
|
+
# => including modules and classes get nothing
|
627
|
+
# => extending modules and classes get nothing
|
628
|
+
# => instances of including and extending classes get nothing
|
629
|
+
# * module included with setting
|
630
|
+
# => singleton gets attr_configuration and configurations
|
631
|
+
# => including modules and classes get attr_configuration and configurations
|
632
|
+
# => instances of including classes get configurations
|
633
|
+
# => extending modules and classes get attr_configuration and configurations
|
634
|
+
# => instances of extending classes get nothing
|
635
|
+
module CascadingConfiguration::Array::Unique::ObjectConfigurationMockModuleExtended
|
636
|
+
extend CascadingConfiguration::Array::Unique
|
637
|
+
# => singleton gets attr_configuration and configurations
|
638
|
+
respond_to?( :attr_object_configuration_unique_array ).should == true
|
639
|
+
attr_object_configuration_unique_array :configuration_setting
|
640
|
+
respond_to?( :configuration_setting ).should == true
|
641
|
+
configuration_setting.should == []
|
642
|
+
configuration_setting.push( :a_configuration )
|
643
|
+
configuration_setting.should == [ :a_configuration ]
|
644
|
+
instance_methods.include?( :configuration_setting ).should == false
|
645
|
+
instance_variables.empty?.should == true
|
646
|
+
# => including modules and classes get nothing
|
647
|
+
module SubmoduleIncluding
|
648
|
+
include CascadingConfiguration::Array::Unique::ObjectConfigurationMockModuleExtended
|
649
|
+
instance_methods.include?( :configuration_setting ).should == false
|
650
|
+
respond_to?( :configuration_setting ).should == false
|
651
|
+
instance_variables.empty?.should == true
|
652
|
+
end
|
653
|
+
# => extending modules and classes get nothing
|
654
|
+
module SubmoduleExtending
|
655
|
+
extend CascadingConfiguration::Array::Unique::ObjectConfigurationMockModuleExtended
|
656
|
+
instance_methods.include?( :configuration_setting ).should == false
|
657
|
+
respond_to?( :configuration_setting ).should == false
|
658
|
+
instance_variables.empty?.should == true
|
659
|
+
end
|
660
|
+
# => instances of including and extending classes get nothing
|
661
|
+
class ClassIncluding
|
662
|
+
include CascadingConfiguration::Array::Unique::ObjectConfigurationMockModuleExtended
|
663
|
+
instance_methods.include?( :configuration_setting ).should == false
|
664
|
+
respond_to?( :configuration_setting ).should == false
|
665
|
+
instance_variables.empty?.should == true
|
666
|
+
end
|
667
|
+
class ClassExtending
|
668
|
+
extend CascadingConfiguration::Array::Unique::ObjectConfigurationMockModuleExtended
|
669
|
+
instance_methods.include?( :configuration_setting ).should == false
|
670
|
+
respond_to?( :configuration_setting ).should == false
|
671
|
+
instance_variables.empty?.should == true
|
672
|
+
end
|
673
|
+
end
|
674
|
+
|
675
|
+
# * module included with setting
|
676
|
+
module CascadingConfiguration::Array::Unique::ObjectConfigurationMockModuleIncluded
|
677
|
+
include CascadingConfiguration::Array::Unique
|
678
|
+
# => singleton gets attr_configuration and configurations
|
679
|
+
respond_to?( :attr_object_configuration_unique_array ).should == true
|
680
|
+
attr_object_configuration_unique_array :configuration_setting
|
681
|
+
respond_to?( :configuration_setting ).should == true
|
682
|
+
configuration_setting.should == []
|
683
|
+
configuration_setting.push( :a_configuration )
|
684
|
+
configuration_setting.should == [ :a_configuration ]
|
685
|
+
instance_methods.include?( :configuration_setting ).should == false
|
686
|
+
instance_variables.empty?.should == true
|
687
|
+
# => including modules and classes get attr_configuration and configurations
|
688
|
+
module SubmoduleIncluding
|
689
|
+
include CascadingConfiguration::Array::Unique::ObjectConfigurationMockModuleIncluded
|
690
|
+
instance_methods.include?( :configuration_setting ).should == false
|
691
|
+
respond_to?( :configuration_setting ).should == false
|
692
|
+
instance_methods.include?( :configuration_setting ).should == false
|
693
|
+
instance_variables.empty?.should == true
|
694
|
+
end
|
695
|
+
# => extending modules and classes get attr_configuration and configurations
|
696
|
+
module SubmoduleExtending
|
697
|
+
extend CascadingConfiguration::Array::Unique::ObjectConfigurationMockModuleIncluded
|
698
|
+
# if we're extended then we want to use the eigenclass ancestor chain
|
699
|
+
# - the first ancestor will be the extending module
|
700
|
+
# - the rest of the ancestors will be the extending module's include chain
|
701
|
+
respond_to?( :configuration_setting ).should == false
|
702
|
+
instance_methods.include?( :configuration_setting ).should == false
|
703
|
+
instance_variables.empty?.should == true
|
704
|
+
end
|
705
|
+
# => instances of including classes get configurations
|
706
|
+
class ClassIncluding
|
707
|
+
include CascadingConfiguration::Array::Unique::ObjectConfigurationMockModuleIncluded
|
708
|
+
instance_methods.include?( :configuration_setting ).should == false
|
709
|
+
respond_to?( :configuration_setting ).should == false
|
710
|
+
instance_variables.empty?.should == true
|
711
|
+
end
|
712
|
+
setting_class_including_instance = ClassIncluding.new
|
713
|
+
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
714
|
+
setting_class_including_instance.instance_variables.empty?.should == true
|
715
|
+
# => instances of extending classes get nothing
|
716
|
+
class ClassExtending
|
717
|
+
extend CascadingConfiguration::Array::Unique::ObjectConfigurationMockModuleIncluded
|
718
|
+
instance_methods.include?( :configuration_setting ).should == false
|
719
|
+
respond_to?( :configuration_setting ).should == false
|
720
|
+
instance_variables.empty?.should == true
|
721
|
+
end
|
722
|
+
setting_class_including_instance = ClassExtending.new
|
723
|
+
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
724
|
+
setting_class_including_instance.instance_variables.empty?.should == true
|
725
|
+
end
|
726
|
+
|
727
|
+
class CascadingConfiguration::Array::Unique::ObjectConfigurationMockClass
|
728
|
+
include CascadingConfiguration::Array::Unique::ObjectConfigurationMockModuleIncluded::SubmoduleIncluding
|
729
|
+
instance_methods.include?( :configuration_setting ).should == false
|
730
|
+
respond_to?( :configuration_setting ).should == false
|
731
|
+
instance_variables.empty?.should == true
|
732
|
+
end
|
733
|
+
object_instance_one = CascadingConfiguration::Array::Unique::ObjectConfigurationMockClass.new
|
734
|
+
object_instance_one.respond_to?( :configuration_setting ).should == false
|
735
|
+
object_instance_one.instance_variables.empty?.should == true
|
736
|
+
class CascadingConfiguration::Array::Unique::ObjectConfigurationMockClassSub1 < CascadingConfiguration::Array::Unique::ObjectConfigurationMockClass
|
737
|
+
instance_methods.include?( :configuration_setting ).should == false
|
738
|
+
respond_to?( :configuration_setting ).should == false
|
739
|
+
instance_variables.empty?.should == true
|
740
|
+
end
|
741
|
+
object_instance_two = CascadingConfiguration::Array::Unique::ObjectConfigurationMockClassSub1.new
|
742
|
+
object_instance_two.respond_to?( :configuration_setting ).should == false
|
743
|
+
object_instance_two.instance_variables.empty?.should == true
|
744
|
+
class CascadingConfiguration::Array::Unique::ObjectConfigurationMockClassSub2 < CascadingConfiguration::Array::Unique::ObjectConfigurationMockClassSub1
|
745
|
+
instance_methods.include?( :configuration_setting ).should == false
|
746
|
+
respond_to?( :configuration_setting ).should == false
|
747
|
+
instance_variables.empty?.should == true
|
748
|
+
end
|
749
|
+
|
750
|
+
end
|
751
|
+
|
752
|
+
end
|