cascading-configuration-array 2.1.6 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +60 -0
- data/README.md +2 -187
- data/README.rdoc +2 -20
- data/lib/cascading-configuration-array.rb +1 -16
- metadata +15 -10
- data/lib/cascading-configuration-array/CascadingConfiguration/Array.rb +0 -29
- data/spec/CascadingConfiguration/Array_spec.rb +0 -773
data/CHANGELOG.rdoc
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
== 7/13/2011
|
2
|
+
|
3
|
+
Initial release.
|
4
|
+
|
5
|
+
== 7/14/2011
|
6
|
+
|
7
|
+
* CascadingConfiguration::
|
8
|
+
- ConfigurationArray renamed to LocalConfigurationArray
|
9
|
+
- CascadingCompositeArray renamed to ::CompositingArray
|
10
|
+
- ConfigurationSettingsArray renamed to Array
|
11
|
+
|
12
|
+
== 8/8/2011
|
13
|
+
|
14
|
+
Added :attr_object_configuration_array and :attr_instance_configuration_array and refined :attr_local_configuration_array.
|
15
|
+
|
16
|
+
== 1/16/2012
|
17
|
+
|
18
|
+
Major overhaul to internals.
|
19
|
+
Fixes for instances.
|
20
|
+
Fixes for inheritance.
|
21
|
+
Far cleaner, faster, smaller code.
|
22
|
+
Inheritance code is all integrated into cascading-configuration-variable, now, which offers an impressive use-case for module-cluster.
|
23
|
+
|
24
|
+
== 1/18/2012
|
25
|
+
|
26
|
+
Fixes for multiple configuration inheritance. Youngest definition wins.
|
27
|
+
|
28
|
+
== 2/3/2012
|
29
|
+
|
30
|
+
Slimmed down, internals fixes for convenience. Much faster.
|
31
|
+
|
32
|
+
== 2/27/2012
|
33
|
+
|
34
|
+
Changed default behavior for CascadingConfiguration::Array to non-sorted, non-unique.
|
35
|
+
If you want prior behavior, use CascadingConfiguration::Array::Sorted::Unique, provided by cascading-configuration-array-sorted-unique.
|
36
|
+
Now default behaves like a normal array (hopefully in every way).
|
37
|
+
|
38
|
+
It should also be faster.
|
39
|
+
|
40
|
+
NOTE: this breaks + by causing it to modify the array like +=.
|
41
|
+
The alternative was worse.
|
42
|
+
|
43
|
+
== 3/2/2012
|
44
|
+
|
45
|
+
Minor fix for nil parent arrays.
|
46
|
+
|
47
|
+
== 3/4/2012
|
48
|
+
|
49
|
+
Significantly reduced redundant code.
|
50
|
+
Added accessor-utilities support, meaning now configurations can be named with ? at the end, which creates :method? and :method=".
|
51
|
+
|
52
|
+
== 3/18/2012
|
53
|
+
|
54
|
+
Method definition moved to ::CascadingConfiguration::Methods based on configuration method. Less source code to maintain, and easier to add further modules!
|
55
|
+
CompositingArray moved to independent gem (compositing-array).
|
56
|
+
Added compositing object extension support - pass in a module or use a block to define a module or both.
|
57
|
+
|
58
|
+
== 6/18/2012
|
59
|
+
|
60
|
+
Merged into cascading-configuration.
|
data/README.md
CHANGED
@@ -4,201 +4,16 @@ http://rubygems.org/gems/cascading-configuration-array
|
|
4
4
|
|
5
5
|
# Description #
|
6
6
|
|
7
|
-
|
7
|
+
Now just a thin wrapper for cascading-configuration.
|
8
8
|
|
9
9
|
# Summary #
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
This means that we can create configuration modules, optionally setting configuration defaults, and include those configuration modules in other modules or classes.
|
11
|
+
Deprecated.
|
14
12
|
|
15
13
|
# Install #
|
16
14
|
|
17
15
|
* sudo gem install cascading-configuration
|
18
16
|
|
19
|
-
# Usage #
|
20
|
-
|
21
|
-
Including the module will enable support for singleton and for instances.
|
22
|
-
|
23
|
-
```ruby
|
24
|
-
module AnyModuleOrClass
|
25
|
-
include CascadingConfiguration
|
26
|
-
end
|
27
|
-
```
|
28
|
-
|
29
|
-
Extending the module will enable support for singleton only.
|
30
|
-
|
31
|
-
```ruby
|
32
|
-
module AnyModuleOrClass
|
33
|
-
extend CascadingConfiguration
|
34
|
-
end
|
35
|
-
```
|
36
|
-
|
37
|
-
Including or extending CascadingConfiguration includes or extends:
|
38
|
-
|
39
|
-
* CascadingConfiguration::Variable
|
40
|
-
|
41
|
-
## :attr_configuration_array ##
|
42
|
-
|
43
|
-
:attr_configuration_array provides inheritable array configurations that cascade downward. A composite sorted and unique array will be returned (merging downward from most distant ancestor to self).
|
44
|
-
|
45
|
-
An internal cache is kept, and any configuration updates that occur to higher-level ancestors cascade immediately downward.
|
46
|
-
|
47
|
-
The array maintained by :attr_configuration_array is kept ordered and unique.
|
48
|
-
|
49
|
-
Define initial configuration in a module or class:
|
50
|
-
|
51
|
-
```ruby
|
52
|
-
module SomeModule
|
53
|
-
|
54
|
-
include CascadingConfiguration::Array
|
55
|
-
|
56
|
-
attr_array_configuration :some_array_setting
|
57
|
-
|
58
|
-
some_array_setting # => nil
|
59
|
-
|
60
|
-
some_array_setting.push( :some_value )
|
61
|
-
|
62
|
-
some_array_setting # => [ :some_value ]
|
63
|
-
|
64
|
-
end
|
65
|
-
```
|
66
|
-
|
67
|
-
Include initial module in a module or class:
|
68
|
-
|
69
|
-
```ruby
|
70
|
-
class SomeClass
|
71
|
-
|
72
|
-
include SomeModule
|
73
|
-
|
74
|
-
some_array_setting # => [ :some_value ]
|
75
|
-
|
76
|
-
self.some_array_setting = [ :some_other_value ]
|
77
|
-
|
78
|
-
some_array_setting # => [ :some_other_value ]
|
79
|
-
|
80
|
-
some_array_setting.push( :another_value ) # => [ :another_value, :some_other_value ]
|
81
|
-
|
82
|
-
SomeModule.some_array_setting # => [ :some_value ]
|
83
|
-
|
84
|
-
end
|
85
|
-
```
|
86
|
-
|
87
|
-
And it cascades to instances:
|
88
|
-
|
89
|
-
```ruby
|
90
|
-
instance = SomeClass.new
|
91
|
-
|
92
|
-
instance.some_array_setting.should == [ :another_value, :some_other_value ]
|
93
|
-
|
94
|
-
instance.some_array_setting.delete( :some_other_value )
|
95
|
-
|
96
|
-
instance.some_array_setting.should == [ :another_value ]
|
97
|
-
```
|
98
|
-
|
99
|
-
### :attr_module_configuration_array, :attr_class_configuration_array ###
|
100
|
-
|
101
|
-
:attr_class_configuration_array works like :attr_configuration_array but does not cascade to instances.
|
102
|
-
|
103
|
-
```ruby
|
104
|
-
module SomeModule
|
105
|
-
|
106
|
-
include CascadingConfiguration::Array
|
107
|
-
|
108
|
-
attr_array_configuration :some_array_setting
|
109
|
-
|
110
|
-
some_array_setting # => nil
|
111
|
-
|
112
|
-
some_array_setting.push( :some_value )
|
113
|
-
|
114
|
-
some_array_setting # => [ :some_value ]
|
115
|
-
|
116
|
-
end
|
117
|
-
```
|
118
|
-
|
119
|
-
Include initial module in a module or class:
|
120
|
-
|
121
|
-
```ruby
|
122
|
-
class SomeClass
|
123
|
-
|
124
|
-
include SomeModule
|
125
|
-
|
126
|
-
some_array_setting # => [ :some_value ]
|
127
|
-
|
128
|
-
self.some_array_setting = [ :some_other_value ]
|
129
|
-
|
130
|
-
some_array_setting # => [ :some_other_value ]
|
131
|
-
|
132
|
-
some_array_setting.push( :another_value ) # => [ :another_value, :some_other_value ]
|
133
|
-
|
134
|
-
SomeModule.some_array_setting # => [ :some_value ]
|
135
|
-
|
136
|
-
end
|
137
|
-
```
|
138
|
-
|
139
|
-
And it does not cascade to instances:
|
140
|
-
|
141
|
-
```ruby
|
142
|
-
instance = SomeClass.new
|
143
|
-
|
144
|
-
instance.respond_to?( :some_array_setting ).should == false
|
145
|
-
```
|
146
|
-
|
147
|
-
### :attr_local_configuration_array ###
|
148
|
-
|
149
|
-
:attr_local_configuration_array works like :attr_configuration_array but does not cascade. This is primarily useful for creating local configurations maintained in parallel with cascading configurations (for instance, with the same variable prefixes), for overriding the local configuration method, and for hiding the configuration variable (coming soon).
|
150
|
-
|
151
|
-
```ruby
|
152
|
-
module SomeModule
|
153
|
-
|
154
|
-
include CascadingConfiguration::Array
|
155
|
-
|
156
|
-
attr_array_configuration :some_array_setting
|
157
|
-
|
158
|
-
some_array_setting # => nil
|
159
|
-
|
160
|
-
some_array_setting.push( :some_value )
|
161
|
-
|
162
|
-
some_array_setting # => [ :some_value ]
|
163
|
-
|
164
|
-
end
|
165
|
-
```
|
166
|
-
|
167
|
-
Include initial module in a module or class:
|
168
|
-
|
169
|
-
```ruby
|
170
|
-
class SomeClass
|
171
|
-
|
172
|
-
include SomeModule
|
173
|
-
|
174
|
-
respond_to?( :some_array_setting ).should == false
|
175
|
-
|
176
|
-
end
|
177
|
-
```
|
178
|
-
|
179
|
-
## Additional Functionality ##
|
180
|
-
|
181
|
-
Cascading-configuration also provides several other convenience functions.
|
182
|
-
|
183
|
-
### Method Redefinition ###
|
184
|
-
|
185
|
-
Any declared configuration is defined in order to support locally redefining the method and accessing the original by calling super.
|
186
|
-
|
187
|
-
```ruby
|
188
|
-
module SomeModule
|
189
|
-
|
190
|
-
include CascadingConfiguration
|
191
|
-
|
192
|
-
attr_configuration :some_array_setting
|
193
|
-
|
194
|
-
def some_array_setting=( value )
|
195
|
-
puts 'Replacing configuration array!'
|
196
|
-
super
|
197
|
-
end
|
198
|
-
|
199
|
-
end
|
200
|
-
```
|
201
|
-
|
202
17
|
# License #
|
203
18
|
|
204
19
|
(The MIT License)
|
data/README.rdoc
CHANGED
@@ -4,34 +4,16 @@ http://rubygems.org/gems/cascading-configuration-array
|
|
4
4
|
|
5
5
|
== Description
|
6
6
|
|
7
|
-
|
7
|
+
Now just a thin wrapper for cascading-configuration.
|
8
8
|
|
9
9
|
== Summary
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
This means that we can create configuration modules, optionally setting configuration defaults, and include those configuration modules in other modules or classes.
|
14
|
-
|
15
|
-
== :attr_configuration_array
|
16
|
-
|
17
|
-
:attr_configuration_array provides inheritable array configurations that cascade downward. A composite sorted and unique array will be returned (merging downward from most distant ancestor to self).
|
18
|
-
|
19
|
-
An internal cache is kept, and any configuration updates that occur to higher-level ancestors cascade immediately downward.
|
20
|
-
|
21
|
-
The array maintained by :attr_configuration_array is kept ordered and unique.
|
22
|
-
|
23
|
-
:attr_class_configuration_array works like :attr_configuration_array but does not cascade to instances.
|
24
|
-
|
25
|
-
:attr_local_configuration_array works like :attr_configuration_array but does not cascade. This is primarily useful for creating local configurations maintained in parallel with cascading configurations (for instance, with the same variable prefixes), for overriding the local configuration method, and for hiding the configuration variable (coming soon).
|
11
|
+
Deprecated.
|
26
12
|
|
27
13
|
== Install
|
28
14
|
|
29
15
|
* sudo gem install cascading-configuration
|
30
16
|
|
31
|
-
== Usage
|
32
|
-
|
33
|
-
See README.md
|
34
|
-
|
35
17
|
== License
|
36
18
|
|
37
19
|
(The MIT License)
|
@@ -1,17 +1,2 @@
|
|
1
1
|
|
2
|
-
require '
|
3
|
-
|
4
|
-
if $__cascading_configuration__spec__development
|
5
|
-
require_relative '../../definition/lib/cascading-configuration-definition.rb'
|
6
|
-
else
|
7
|
-
require 'cascading-configuration-definition'
|
8
|
-
end
|
9
|
-
|
10
|
-
module ::CascadingConfiguration
|
11
|
-
module Array
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
require_relative 'cascading-configuration-array/CascadingConfiguration/Array.rb'
|
16
|
-
|
17
|
-
|
2
|
+
require 'cascading-configuration'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cascading-configuration-array
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name: cascading-configuration
|
16
|
-
requirement:
|
15
|
+
name: cascading-configuration
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,19 +21,23 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Now just a thin wrapper for cascading-configuration.
|
26
31
|
email: asher@ridiculouspower.com
|
27
32
|
executables: []
|
28
33
|
extensions: []
|
29
34
|
extra_rdoc_files: []
|
30
35
|
files:
|
31
|
-
- lib/cascading-configuration-array/CascadingConfiguration/Array.rb
|
32
36
|
- lib/cascading-configuration-array.rb
|
33
|
-
- spec/CascadingConfiguration/Array_spec.rb
|
34
37
|
- README.md
|
35
38
|
- README.rdoc
|
36
|
-
|
39
|
+
- CHANGELOG.rdoc
|
40
|
+
homepage: http://rubygems.org/gems/cascading-configuration
|
37
41
|
licenses: []
|
38
42
|
post_install_message:
|
39
43
|
rdoc_options: []
|
@@ -53,8 +57,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
57
|
version: '0'
|
54
58
|
requirements: []
|
55
59
|
rubyforge_project: cascading-configuration-array
|
56
|
-
rubygems_version: 1.8.
|
60
|
+
rubygems_version: 1.8.23
|
57
61
|
signing_key:
|
58
62
|
specification_version: 3
|
59
63
|
summary: Support package for cascading-configuration.
|
60
64
|
test_files: []
|
65
|
+
has_rdoc:
|
@@ -1,29 +0,0 @@
|
|
1
|
-
|
2
|
-
module ::CascadingConfiguration::Array
|
3
|
-
|
4
|
-
# Configuration modules for storage of settings arrays
|
5
|
-
include ::CascadingConfiguration::Inheritance
|
6
|
-
|
7
|
-
#######################################
|
8
|
-
# attr_configuration_array #
|
9
|
-
# attr_module_configuration_array #
|
10
|
-
# attr_local_configuration_array #
|
11
|
-
# attr_object_configuration_array #
|
12
|
-
# attr_instance_configuration_array #
|
13
|
-
#######################################
|
14
|
-
|
15
|
-
def attr_configuration_array( *configuration_names, & define_block ) ;; end
|
16
|
-
def attr_module_configuration_array( *configuration_names, & define_block ) ;; end
|
17
|
-
def attr_class_configuration_array( *configuration_names, & define_block ) ;; end
|
18
|
-
def attr_local_configuration_array( *configuration_names, & define_block ) ;; end
|
19
|
-
def attr_object_configuration_array( *configuration_names, & define_block ) ;; end
|
20
|
-
def attr_instance_configuration_array( *configuration_names, & define_block ) ;; end
|
21
|
-
|
22
|
-
ccd = ::CascadingConfiguration::Definition
|
23
|
-
|
24
|
-
ccd.declare_compositing_configuration_object( self, :array, ::CompositingArray )
|
25
|
-
|
26
|
-
# To the tune of "The Events Leading Up to the Collapse of Detective Dulllight"
|
27
|
-
# ~Oh where did all the code go? / Did you think that it'd stick around for-ever?~
|
28
|
-
|
29
|
-
end
|
@@ -1,773 +0,0 @@
|
|
1
|
-
|
2
|
-
if $__cascading_configuration__spec__development
|
3
|
-
require_relative '../../lib/cascading-configuration-array.rb'
|
4
|
-
else
|
5
|
-
require 'cascading-configuration-array'
|
6
|
-
end
|
7
|
-
|
8
|
-
describe CascadingConfiguration::Array do
|
9
|
-
|
10
|
-
##############################
|
11
|
-
# attr_configuration_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::ConfigurationMockModuleExtended
|
29
|
-
extend CascadingConfiguration::Array
|
30
|
-
# => singleton gets attr_configuration and configurations
|
31
|
-
respond_to?( :attr_configuration_array ).should == true
|
32
|
-
attr_configuration_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::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::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::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::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::ConfigurationMockModuleIncluded
|
70
|
-
include CascadingConfiguration::Array
|
71
|
-
# => singleton gets attr_configuration and configurations
|
72
|
-
respond_to?( :attr_configuration_array ).should == true
|
73
|
-
attr_configuration_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::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.should == [ :a_configuration, :another_configuration ]
|
88
|
-
instance_variables.empty?.should == true
|
89
|
-
end
|
90
|
-
# => extending modules and classes get attr_configuration and configurations
|
91
|
-
module SubmoduleExtending
|
92
|
-
extend CascadingConfiguration::Array::ConfigurationMockModuleIncluded
|
93
|
-
# if we're extended then we want to use the eigenclass ancestor chain
|
94
|
-
# - the first ancestor will be the extending module
|
95
|
-
# - the rest of the ancestors will be the extending module's include chain
|
96
|
-
respond_to?( :configuration_setting ).should == true
|
97
|
-
configuration_setting.should == [ :a_configuration ]
|
98
|
-
configuration_setting.push( :some_other_configuration )
|
99
|
-
configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
100
|
-
instance_methods.include?( :configuration_setting ).should == false
|
101
|
-
instance_variables.empty?.should == true
|
102
|
-
end
|
103
|
-
# => instances of including classes get configurations
|
104
|
-
class ClassIncluding
|
105
|
-
include CascadingConfiguration::Array::ConfigurationMockModuleIncluded
|
106
|
-
instance_methods.include?( :configuration_setting ).should == true
|
107
|
-
respond_to?( :configuration_setting ).should == true
|
108
|
-
configuration_setting.should == [ :a_configuration ]
|
109
|
-
configuration_setting.push( :some_other_configuration )
|
110
|
-
configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
111
|
-
instance_variables.empty?.should == true
|
112
|
-
end
|
113
|
-
setting_class_including_instance = ClassIncluding.new
|
114
|
-
setting_class_including_instance.respond_to?( :configuration_setting ).should == true
|
115
|
-
setting_class_including_instance.configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
116
|
-
setting_class_including_instance.configuration_setting.delete( :some_other_configuration )
|
117
|
-
setting_class_including_instance.configuration_setting = [ :our_setting_value ]
|
118
|
-
setting_class_including_instance.configuration_setting.should == [ :our_setting_value ]
|
119
|
-
setting_class_including_instance.instance_variables.empty?.should == true
|
120
|
-
# => instances of extending classes get nothing
|
121
|
-
class ClassExtending
|
122
|
-
extend CascadingConfiguration::Array::ConfigurationMockModuleIncluded
|
123
|
-
respond_to?( :configuration_setting ).should == true
|
124
|
-
configuration_setting.should == [ :a_configuration ]
|
125
|
-
configuration_setting.push( :some_other_configuration )
|
126
|
-
configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
127
|
-
instance_variables.empty?.should == true
|
128
|
-
end
|
129
|
-
setting_class_including_instance = ClassExtending.new
|
130
|
-
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
131
|
-
setting_class_including_instance.instance_variables.empty?.should == true
|
132
|
-
end
|
133
|
-
|
134
|
-
class CascadingConfiguration::Array::ConfigurationMockClass
|
135
|
-
include CascadingConfiguration::Array::ConfigurationMockModuleIncluded::SubmoduleIncluding
|
136
|
-
configuration_setting.should == [ :a_configuration, :another_configuration ]
|
137
|
-
configuration_setting.push( :some_other_configuration )
|
138
|
-
configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
139
|
-
instance_variables.empty?.should == true
|
140
|
-
end
|
141
|
-
object_instance_one = CascadingConfiguration::Array::ConfigurationMockClass.new
|
142
|
-
object_instance_one.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
143
|
-
object_instance_one.configuration_setting.delete( :a_configuration )
|
144
|
-
object_instance_one.configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
145
|
-
object_instance_one.instance_variables.empty?.should == true
|
146
|
-
class CascadingConfiguration::Array::ConfigurationMockClassSub1 < CascadingConfiguration::Array::ConfigurationMockClass
|
147
|
-
configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
148
|
-
configuration_setting.delete( :a_configuration )
|
149
|
-
configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
150
|
-
instance_variables.empty?.should == true
|
151
|
-
end
|
152
|
-
object_instance_two = CascadingConfiguration::Array::ConfigurationMockClassSub1.new
|
153
|
-
object_instance_two.configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
154
|
-
object_instance_two.configuration_setting.delete( :another_configuration )
|
155
|
-
object_instance_two.configuration_setting.should == [ :some_other_configuration ]
|
156
|
-
object_instance_two.instance_variables.empty?.should == true
|
157
|
-
class CascadingConfiguration::Array::ConfigurationMockClassSub2 < CascadingConfiguration::Array::ConfigurationMockClassSub1
|
158
|
-
configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
159
|
-
#configuration_setting.push( :yet_another_configuration )
|
160
|
-
#configuration_setting.should == [ :another_configuration, :some_other_configuration, :yet_another_configuration ]
|
161
|
-
instance_variables.empty?.should == true
|
162
|
-
end
|
163
|
-
|
164
|
-
# change ancestor setting
|
165
|
-
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
166
|
-
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.push( :a_yet_unused_configuration )
|
167
|
-
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
168
|
-
object_instance_one.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
169
|
-
CascadingConfiguration::Array::ConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
170
|
-
object_instance_two.configuration_setting.should == [ :some_other_configuration, :a_yet_unused_configuration ]
|
171
|
-
|
172
|
-
# freeze ancestor setting
|
173
|
-
object_instance_one.configuration_setting.freeze!
|
174
|
-
object_instance_one.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
175
|
-
CascadingConfiguration::Array::ConfigurationMockClassSub1.configuration_setting.freeze!
|
176
|
-
CascadingConfiguration::Array::ConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
177
|
-
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.push( :non_cascading_configuration )
|
178
|
-
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration, :a_yet_unused_configuration, :non_cascading_configuration ]
|
179
|
-
object_instance_one.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
180
|
-
CascadingConfiguration::Array::ConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
181
|
-
object_instance_two.configuration_setting.should == [ :some_other_configuration, :a_yet_unused_configuration ]
|
182
|
-
|
183
|
-
end
|
184
|
-
|
185
|
-
#####################################
|
186
|
-
# attr_module_configuration_array #
|
187
|
-
# attr_class_configuration_array #
|
188
|
-
#####################################
|
189
|
-
|
190
|
-
it 'can define a class configuration array, which will not cascade to instances' do
|
191
|
-
|
192
|
-
# possibilities:
|
193
|
-
# * module extended with setting
|
194
|
-
# => singleton gets attr_configuration and configurations
|
195
|
-
# => including modules and classes get nothing
|
196
|
-
# => extending modules and classes get nothing
|
197
|
-
# => instances of including and extending classes get nothing
|
198
|
-
# * module included with setting
|
199
|
-
# => singleton gets attr_configuration and configurations
|
200
|
-
# => including modules and classes get attr_configuration and configurations
|
201
|
-
# => instances of including classes get configurations
|
202
|
-
# => extending modules and classes get attr_configuration and configurations
|
203
|
-
# => instances of extending classes get nothing
|
204
|
-
module ::CascadingConfiguration::Array::ClassConfigurationMockModuleExtended
|
205
|
-
extend CascadingConfiguration::Array
|
206
|
-
# => singleton gets attr_configuration and configurations
|
207
|
-
respond_to?( :attr_module_configuration_array ).should == true
|
208
|
-
method( :attr_module_configuration_array ).should == method( :attr_class_configuration_array )
|
209
|
-
attr_module_configuration_array :configuration_setting
|
210
|
-
respond_to?( :configuration_setting ).should == true
|
211
|
-
configuration_setting.should == []
|
212
|
-
configuration_setting.push( :a_configuration )
|
213
|
-
configuration_setting.should == [ :a_configuration ]
|
214
|
-
instance_methods.include?( :configuration_setting ).should == false
|
215
|
-
instance_variables.empty?.should == true
|
216
|
-
# => including modules and classes get nothing
|
217
|
-
module SubmoduleIncluding
|
218
|
-
include CascadingConfiguration::Array::ClassConfigurationMockModuleExtended
|
219
|
-
instance_methods.include?( :configuration_setting ).should == false
|
220
|
-
respond_to?( :configuration_setting ).should == false
|
221
|
-
instance_variables.empty?.should == true
|
222
|
-
end
|
223
|
-
# => extending modules and classes get nothing
|
224
|
-
module SubmoduleExtending
|
225
|
-
extend CascadingConfiguration::Array::ClassConfigurationMockModuleExtended
|
226
|
-
instance_methods.include?( :configuration_setting ).should == false
|
227
|
-
respond_to?( :configuration_setting ).should == false
|
228
|
-
instance_variables.empty?.should == true
|
229
|
-
end
|
230
|
-
# => instances of including and extending classes get nothing
|
231
|
-
class ClassIncluding
|
232
|
-
include CascadingConfiguration::Array::ClassConfigurationMockModuleExtended
|
233
|
-
instance_methods.include?( :configuration_setting ).should == false
|
234
|
-
respond_to?( :configuration_setting ).should == false
|
235
|
-
instance_variables.empty?.should == true
|
236
|
-
end
|
237
|
-
class ClassExtending
|
238
|
-
extend CascadingConfiguration::Array::ClassConfigurationMockModuleExtended
|
239
|
-
instance_methods.include?( :configuration_setting ).should == false
|
240
|
-
respond_to?( :configuration_setting ).should == false
|
241
|
-
instance_variables.empty?.should == true
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
# * module included with setting
|
246
|
-
module ::CascadingConfiguration::Array::ClassConfigurationMockModuleIncluded
|
247
|
-
include CascadingConfiguration::Array
|
248
|
-
# => singleton gets attr_configuration and configurations
|
249
|
-
respond_to?( :attr_module_configuration_array ).should == true
|
250
|
-
attr_module_configuration_array :configuration_setting
|
251
|
-
respond_to?( :configuration_setting ).should == true
|
252
|
-
configuration_setting.should == []
|
253
|
-
configuration_setting.push( :a_configuration )
|
254
|
-
configuration_setting.should == [ :a_configuration ]
|
255
|
-
instance_methods.include?( :configuration_setting ).should == false
|
256
|
-
instance_variables.empty?.should == true
|
257
|
-
# => including modules and classes get attr_configuration and configurations
|
258
|
-
module SubmoduleIncluding
|
259
|
-
include CascadingConfiguration::Array::ClassConfigurationMockModuleIncluded
|
260
|
-
instance_methods.include?( :configuration_setting ).should == false
|
261
|
-
respond_to?( :configuration_setting ).should == true
|
262
|
-
configuration_setting.should == [ :a_configuration ]
|
263
|
-
configuration_setting.push( :another_configuration )
|
264
|
-
configuration_setting.should == [ :a_configuration, :another_configuration ]
|
265
|
-
instance_methods.include?( :configuration_setting ).should == false
|
266
|
-
instance_variables.empty?.should == true
|
267
|
-
end
|
268
|
-
# => extending modules and classes get attr_configuration and configurations
|
269
|
-
module SubmoduleExtending
|
270
|
-
extend CascadingConfiguration::Array::ClassConfigurationMockModuleIncluded
|
271
|
-
# if we're extended then we want to use the eigenclass ancestor chain
|
272
|
-
# - the first ancestor will be the extending module
|
273
|
-
# - the rest of the ancestors will be the extending module's include chain
|
274
|
-
respond_to?( :configuration_setting ).should == true
|
275
|
-
configuration_setting.should == [ :a_configuration ]
|
276
|
-
configuration_setting.push( :some_other_configuration )
|
277
|
-
configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
278
|
-
instance_methods.include?( :configuration_setting ).should == false
|
279
|
-
instance_variables.empty?.should == true
|
280
|
-
end
|
281
|
-
# => instances of including classes get configurations
|
282
|
-
class ClassIncluding
|
283
|
-
include CascadingConfiguration::Array::ClassConfigurationMockModuleIncluded
|
284
|
-
instance_methods.include?( :configuration_setting ).should == false
|
285
|
-
respond_to?( :configuration_setting ).should == true
|
286
|
-
configuration_setting.should == [ :a_configuration ]
|
287
|
-
configuration_setting.push( :some_other_configuration )
|
288
|
-
configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
289
|
-
instance_variables.empty?.should == true
|
290
|
-
end
|
291
|
-
setting_class_including_instance = ClassIncluding.new
|
292
|
-
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
293
|
-
setting_class_including_instance.instance_variables.empty?.should == true
|
294
|
-
# => instances of extending classes get nothing
|
295
|
-
class ClassExtending
|
296
|
-
extend CascadingConfiguration::Array::ClassConfigurationMockModuleIncluded
|
297
|
-
instance_methods.include?( :configuration_setting ).should == false
|
298
|
-
respond_to?( :configuration_setting ).should == true
|
299
|
-
configuration_setting.should == [ :a_configuration ]
|
300
|
-
configuration_setting.push( :some_other_configuration )
|
301
|
-
configuration_setting.should == [ :a_configuration, :some_other_configuration ]
|
302
|
-
instance_variables.empty?.should == true
|
303
|
-
end
|
304
|
-
setting_class_including_instance = ClassExtending.new
|
305
|
-
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
306
|
-
setting_class_including_instance.instance_variables.empty?.should == true
|
307
|
-
end
|
308
|
-
|
309
|
-
class CascadingConfiguration::Array::ClassConfigurationMockClass
|
310
|
-
include CascadingConfiguration::Array::ClassConfigurationMockModuleIncluded::SubmoduleIncluding
|
311
|
-
instance_methods.include?( :configuration_setting ).should == false
|
312
|
-
configuration_setting.should == [ :a_configuration, :another_configuration ]
|
313
|
-
configuration_setting.push( :some_other_configuration )
|
314
|
-
configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
315
|
-
instance_variables.empty?.should == true
|
316
|
-
end
|
317
|
-
object_instance_one = CascadingConfiguration::Array::ClassConfigurationMockClass.new
|
318
|
-
object_instance_one.respond_to?( :configuration_setting ).should == false
|
319
|
-
object_instance_one.instance_variables.empty?.should == true
|
320
|
-
class CascadingConfiguration::Array::ClassConfigurationMockClassSub1 < CascadingConfiguration::Array::ClassConfigurationMockClass
|
321
|
-
instance_methods.include?( :configuration_setting ).should == false
|
322
|
-
configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
323
|
-
configuration_setting.delete( :a_configuration )
|
324
|
-
configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
325
|
-
instance_variables.empty?.should == true
|
326
|
-
end
|
327
|
-
object_instance_two = CascadingConfiguration::Array::ClassConfigurationMockClassSub1.new
|
328
|
-
object_instance_two.respond_to?( :configuration_setting ).should == false
|
329
|
-
object_instance_two.instance_variables.empty?.should == true
|
330
|
-
class CascadingConfiguration::Array::ClassConfigurationMockClassSub2 < CascadingConfiguration::Array::ClassConfigurationMockClassSub1
|
331
|
-
instance_methods.include?( :configuration_setting ).should == false
|
332
|
-
configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
333
|
-
configuration_setting.push( :yet_another_configuration )
|
334
|
-
configuration_setting.should == [ :another_configuration, :some_other_configuration, :yet_another_configuration ]
|
335
|
-
instance_variables.empty?.should == true
|
336
|
-
end
|
337
|
-
|
338
|
-
# change ancestor setting
|
339
|
-
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
340
|
-
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.push( :a_yet_unused_configuration )
|
341
|
-
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
342
|
-
CascadingConfiguration::Array::ClassConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
343
|
-
|
344
|
-
# freeze ancestor setting
|
345
|
-
CascadingConfiguration::Array::ClassConfigurationMockClassSub1.configuration_setting.freeze!
|
346
|
-
CascadingConfiguration::Array::ClassConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
347
|
-
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.push( :non_cascading_configuration )
|
348
|
-
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration, :a_yet_unused_configuration, :non_cascading_configuration ]
|
349
|
-
CascadingConfiguration::Array::ClassConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
350
|
-
|
351
|
-
end
|
352
|
-
|
353
|
-
####################################
|
354
|
-
# attr_local_configuration_array #
|
355
|
-
####################################
|
356
|
-
|
357
|
-
it 'can define a local configuration array, which will not cascade' do
|
358
|
-
|
359
|
-
# possibilities:
|
360
|
-
# * module extended with setting
|
361
|
-
# => singleton gets attr_configuration and configurations
|
362
|
-
# => including modules and classes get nothing
|
363
|
-
# => extending modules and classes get nothing
|
364
|
-
# => instances of including and extending classes get nothing
|
365
|
-
# * module included with setting
|
366
|
-
# => singleton gets attr_configuration and configurations
|
367
|
-
# => including modules and classes get attr_configuration and configurations
|
368
|
-
# => instances of including classes get configurations
|
369
|
-
# => extending modules and classes get attr_configuration and configurations
|
370
|
-
# => instances of extending classes get nothing
|
371
|
-
module ::CascadingConfiguration::Array::LocalConfigurationMockModuleExtended
|
372
|
-
extend CascadingConfiguration::Array
|
373
|
-
# => singleton gets attr_configuration and configurations
|
374
|
-
respond_to?( :attr_local_configuration_array ).should == true
|
375
|
-
attr_local_configuration_array :configuration_setting
|
376
|
-
respond_to?( :configuration_setting ).should == true
|
377
|
-
configuration_setting.should == []
|
378
|
-
configuration_setting.push( :a_configuration )
|
379
|
-
configuration_setting.should == [ :a_configuration ]
|
380
|
-
instance_methods.include?( :configuration_setting ).should == false
|
381
|
-
instance_variables.empty?.should == true
|
382
|
-
# => including modules and classes get nothing
|
383
|
-
module SubmoduleIncluding
|
384
|
-
include CascadingConfiguration::Array::LocalConfigurationMockModuleExtended
|
385
|
-
instance_methods.include?( :configuration_setting ).should == false
|
386
|
-
respond_to?( :configuration_setting ).should == false
|
387
|
-
instance_variables.empty?.should == true
|
388
|
-
end
|
389
|
-
# => extending modules and classes get nothing
|
390
|
-
module SubmoduleExtending
|
391
|
-
extend CascadingConfiguration::Array::LocalConfigurationMockModuleExtended
|
392
|
-
instance_methods.include?( :configuration_setting ).should == false
|
393
|
-
respond_to?( :configuration_setting ).should == false
|
394
|
-
instance_variables.empty?.should == true
|
395
|
-
end
|
396
|
-
# => instances of including and extending classes get nothing
|
397
|
-
class ClassIncluding
|
398
|
-
include CascadingConfiguration::Array::LocalConfigurationMockModuleExtended
|
399
|
-
instance_methods.include?( :configuration_setting ).should == false
|
400
|
-
respond_to?( :configuration_setting ).should == false
|
401
|
-
instance_variables.empty?.should == true
|
402
|
-
end
|
403
|
-
class ClassExtending
|
404
|
-
extend CascadingConfiguration::Array::LocalConfigurationMockModuleExtended
|
405
|
-
instance_methods.include?( :configuration_setting ).should == false
|
406
|
-
respond_to?( :configuration_setting ).should == false
|
407
|
-
instance_variables.empty?.should == true
|
408
|
-
end
|
409
|
-
end
|
410
|
-
|
411
|
-
# * module included with setting
|
412
|
-
module ::CascadingConfiguration::Array::LocalConfigurationMockModuleIncluded
|
413
|
-
include CascadingConfiguration::Array
|
414
|
-
# => singleton gets attr_configuration and configurations
|
415
|
-
respond_to?( :attr_local_configuration_array ).should == true
|
416
|
-
attr_local_configuration_array :configuration_setting
|
417
|
-
respond_to?( :configuration_setting ).should == true
|
418
|
-
configuration_setting.should == []
|
419
|
-
configuration_setting.push( :a_configuration )
|
420
|
-
configuration_setting.should == [ :a_configuration ]
|
421
|
-
instance_methods.include?( :configuration_setting ).should == true
|
422
|
-
instance_variables.empty?.should == true
|
423
|
-
# => including modules and classes get attr_configuration and configurations
|
424
|
-
module SubmoduleIncluding
|
425
|
-
include CascadingConfiguration::Array::LocalConfigurationMockModuleIncluded
|
426
|
-
instance_methods.include?( :configuration_setting ).should == true
|
427
|
-
respond_to?( :configuration_setting ).should == false
|
428
|
-
instance_variables.empty?.should == true
|
429
|
-
end
|
430
|
-
# => extending modules and classes get attr_configuration and configurations
|
431
|
-
module SubmoduleExtending
|
432
|
-
extend CascadingConfiguration::Array::LocalConfigurationMockModuleIncluded
|
433
|
-
# if we're extended then we want to use the eigenclass ancestor chain
|
434
|
-
# - the first ancestor will be the extending module
|
435
|
-
# - the rest of the ancestors will be the extending module's include chain
|
436
|
-
respond_to?( :configuration_setting ).should == true
|
437
|
-
instance_methods.include?( :configuration_setting ).should == false
|
438
|
-
instance_variables.empty?.should == true
|
439
|
-
end
|
440
|
-
# => instances of including classes get configurations
|
441
|
-
class ClassIncluding
|
442
|
-
include CascadingConfiguration::Array::LocalConfigurationMockModuleIncluded
|
443
|
-
instance_methods.include?( :configuration_setting ).should == true
|
444
|
-
respond_to?( :configuration_setting ).should == false
|
445
|
-
instance_variables.empty?.should == true
|
446
|
-
end
|
447
|
-
setting_class_including_instance = ClassIncluding.new
|
448
|
-
setting_class_including_instance.respond_to?( :configuration_setting ).should == true
|
449
|
-
setting_class_including_instance.instance_variables.empty?.should == true
|
450
|
-
# => instances of extending classes get nothing
|
451
|
-
class ClassExtending
|
452
|
-
extend CascadingConfiguration::Array::LocalConfigurationMockModuleIncluded
|
453
|
-
instance_methods.include?( :configuration_setting ).should == false
|
454
|
-
respond_to?( :configuration_setting ).should == true
|
455
|
-
instance_variables.empty?.should == true
|
456
|
-
end
|
457
|
-
setting_class_including_instance = ClassExtending.new
|
458
|
-
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
459
|
-
setting_class_including_instance.instance_variables.empty?.should == true
|
460
|
-
end
|
461
|
-
|
462
|
-
class CascadingConfiguration::Array::LocalConfigurationMockClass
|
463
|
-
include CascadingConfiguration::Array::LocalConfigurationMockModuleIncluded::SubmoduleIncluding
|
464
|
-
instance_methods.include?( :configuration_setting ).should == true
|
465
|
-
respond_to?( :configuration_setting ).should == false
|
466
|
-
instance_variables.empty?.should == true
|
467
|
-
end
|
468
|
-
object_instance_one = CascadingConfiguration::Array::LocalConfigurationMockClass.new
|
469
|
-
object_instance_one.respond_to?( :configuration_setting ).should == true
|
470
|
-
object_instance_one.instance_variables.empty?.should == true
|
471
|
-
class CascadingConfiguration::Array::LocalConfigurationMockClassSub1 < CascadingConfiguration::Array::LocalConfigurationMockClass
|
472
|
-
instance_methods.include?( :configuration_setting ).should == true
|
473
|
-
respond_to?( :configuration_setting ).should == false
|
474
|
-
instance_variables.empty?.should == true
|
475
|
-
end
|
476
|
-
object_instance_two = CascadingConfiguration::Array::LocalConfigurationMockClassSub1.new
|
477
|
-
object_instance_two.respond_to?( :configuration_setting ).should == true
|
478
|
-
object_instance_two.instance_variables.empty?.should == true
|
479
|
-
class CascadingConfiguration::Array::LocalConfigurationMockClassSub2 < CascadingConfiguration::Array::LocalConfigurationMockClassSub1
|
480
|
-
instance_methods.include?( :configuration_setting ).should == true
|
481
|
-
respond_to?( :configuration_setting ).should == false
|
482
|
-
instance_variables.empty?.should == true
|
483
|
-
end
|
484
|
-
|
485
|
-
end
|
486
|
-
|
487
|
-
#######################################
|
488
|
-
# attr_instance_configuration_array #
|
489
|
-
#######################################
|
490
|
-
|
491
|
-
it 'can define an instance configuration array, which will not cascade' do
|
492
|
-
|
493
|
-
# possibilities:
|
494
|
-
# * module extended with setting
|
495
|
-
# => singleton gets attr_configuration and configurations
|
496
|
-
# => including modules and classes get nothing
|
497
|
-
# => extending modules and classes get nothing
|
498
|
-
# => instances of including and extending classes get nothing
|
499
|
-
# * module included with setting
|
500
|
-
# => singleton gets attr_configuration and configurations
|
501
|
-
# => including modules and classes get attr_configuration and configurations
|
502
|
-
# => instances of including classes get configurations
|
503
|
-
# => extending modules and classes get attr_configuration and configurations
|
504
|
-
# => instances of extending classes get nothing
|
505
|
-
module ::CascadingConfiguration::Array::InstanceConfigurationMockModuleExtended
|
506
|
-
extend CascadingConfiguration::Array
|
507
|
-
# => singleton gets attr_configuration and configurations
|
508
|
-
instance_variables.empty?.should == true
|
509
|
-
# => including modules and classes get nothing
|
510
|
-
module SubmoduleIncluding
|
511
|
-
include CascadingConfiguration::Array::InstanceConfigurationMockModuleExtended
|
512
|
-
instance_methods.include?( :configuration_setting ).should == false
|
513
|
-
respond_to?( :configuration_setting ).should == false
|
514
|
-
instance_variables.empty?.should == true
|
515
|
-
end
|
516
|
-
# => extending modules and classes get nothing
|
517
|
-
module SubmoduleExtending
|
518
|
-
extend CascadingConfiguration::Array::InstanceConfigurationMockModuleExtended
|
519
|
-
instance_methods.include?( :configuration_setting ).should == false
|
520
|
-
respond_to?( :configuration_setting ).should == false
|
521
|
-
instance_variables.empty?.should == true
|
522
|
-
end
|
523
|
-
# => instances of including and extending classes get nothing
|
524
|
-
class ClassIncluding
|
525
|
-
include CascadingConfiguration::Array::InstanceConfigurationMockModuleExtended
|
526
|
-
instance_methods.include?( :configuration_setting ).should == false
|
527
|
-
respond_to?( :configuration_setting ).should == false
|
528
|
-
instance_variables.empty?.should == true
|
529
|
-
end
|
530
|
-
class ClassExtending
|
531
|
-
extend CascadingConfiguration::Array::InstanceConfigurationMockModuleExtended
|
532
|
-
instance_methods.include?( :configuration_setting ).should == false
|
533
|
-
respond_to?( :configuration_setting ).should == false
|
534
|
-
instance_variables.empty?.should == true
|
535
|
-
end
|
536
|
-
end
|
537
|
-
|
538
|
-
# * module included with setting
|
539
|
-
module ::CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded
|
540
|
-
include CascadingConfiguration::Array
|
541
|
-
# => singleton gets attr_configuration and configurations
|
542
|
-
respond_to?( :attr_instance_configuration_array ).should == true
|
543
|
-
attr_instance_configuration_array :configuration_setting
|
544
|
-
respond_to?( :configuration_setting ).should == false
|
545
|
-
instance_methods.include?( :configuration_setting ).should == true
|
546
|
-
instance_variables.empty?.should == true
|
547
|
-
# => including modules and classes get attr_configuration and configurations
|
548
|
-
module SubmoduleIncluding
|
549
|
-
include CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded
|
550
|
-
instance_methods.include?( :configuration_setting ).should == true
|
551
|
-
respond_to?( :configuration_setting ).should == false
|
552
|
-
instance_methods.include?( :configuration_setting ).should == true
|
553
|
-
instance_variables.empty?.should == true
|
554
|
-
end
|
555
|
-
# => extending modules and classes get attr_configuration and configurations
|
556
|
-
module SubmoduleExtending
|
557
|
-
extend CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded
|
558
|
-
# if we're extended then we want to use the eigenclass ancestor chain
|
559
|
-
# - the first ancestor will be the extending module
|
560
|
-
# - the rest of the ancestors will be the extending module's include chain
|
561
|
-
respond_to?( :configuration_setting ).should == true
|
562
|
-
instance_methods.include?( :configuration_setting ).should == false
|
563
|
-
instance_variables.empty?.should == true
|
564
|
-
end
|
565
|
-
# => instances of including classes get configurations
|
566
|
-
class ClassIncluding
|
567
|
-
include CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded
|
568
|
-
instance_methods.include?( :configuration_setting ).should == true
|
569
|
-
respond_to?( :configuration_setting ).should == false
|
570
|
-
instance_variables.empty?.should == true
|
571
|
-
end
|
572
|
-
setting_class_including_instance = ClassIncluding.new
|
573
|
-
setting_class_including_instance.respond_to?( :configuration_setting ).should == true
|
574
|
-
setting_class_including_instance.instance_variables.empty?.should == true
|
575
|
-
# => instances of extending classes get nothing
|
576
|
-
class ClassExtending
|
577
|
-
extend CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded
|
578
|
-
instance_methods.include?( :configuration_setting ).should == false
|
579
|
-
respond_to?( :configuration_setting ).should == true
|
580
|
-
instance_variables.empty?.should == true
|
581
|
-
end
|
582
|
-
setting_class_including_instance = ClassExtending.new
|
583
|
-
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
584
|
-
setting_class_including_instance.instance_variables.empty?.should == true
|
585
|
-
end
|
586
|
-
|
587
|
-
class CascadingConfiguration::Array::InstanceConfigurationMockClass
|
588
|
-
include CascadingConfiguration::Array::InstanceConfigurationMockModuleIncluded::SubmoduleIncluding
|
589
|
-
instance_methods.include?( :configuration_setting ).should == true
|
590
|
-
respond_to?( :configuration_setting ).should == false
|
591
|
-
instance_variables.empty?.should == true
|
592
|
-
end
|
593
|
-
object_instance_one = CascadingConfiguration::Array::InstanceConfigurationMockClass.new
|
594
|
-
object_instance_one.respond_to?( :configuration_setting ).should == true
|
595
|
-
object_instance_one.instance_variables.empty?.should == true
|
596
|
-
class CascadingConfiguration::Array::InstanceConfigurationMockClassSub1 < CascadingConfiguration::Array::InstanceConfigurationMockClass
|
597
|
-
instance_methods.include?( :configuration_setting ).should == true
|
598
|
-
respond_to?( :configuration_setting ).should == false
|
599
|
-
instance_variables.empty?.should == true
|
600
|
-
end
|
601
|
-
object_instance_two = CascadingConfiguration::Array::InstanceConfigurationMockClassSub1.new
|
602
|
-
object_instance_two.respond_to?( :configuration_setting ).should == true
|
603
|
-
object_instance_two.instance_variables.empty?.should == true
|
604
|
-
class CascadingConfiguration::Array::InstanceConfigurationMockClassSub2 < CascadingConfiguration::Array::InstanceConfigurationMockClassSub1
|
605
|
-
instance_methods.include?( :configuration_setting ).should == true
|
606
|
-
respond_to?( :configuration_setting ).should == false
|
607
|
-
instance_variables.empty?.should == true
|
608
|
-
end
|
609
|
-
|
610
|
-
end
|
611
|
-
|
612
|
-
|
613
|
-
#####################################
|
614
|
-
# attr_object_configuration_array #
|
615
|
-
#####################################
|
616
|
-
|
617
|
-
it 'can define an object configuration array, which will not cascade' do
|
618
|
-
|
619
|
-
# possibilities:
|
620
|
-
# * module extended with setting
|
621
|
-
# => singleton gets attr_configuration and configurations
|
622
|
-
# => including modules and classes get nothing
|
623
|
-
# => extending modules and classes get nothing
|
624
|
-
# => instances of including and extending classes get nothing
|
625
|
-
# * module included with setting
|
626
|
-
# => singleton gets attr_configuration and configurations
|
627
|
-
# => including modules and classes get attr_configuration and configurations
|
628
|
-
# => instances of including classes get configurations
|
629
|
-
# => extending modules and classes get attr_configuration and configurations
|
630
|
-
# => instances of extending classes get nothing
|
631
|
-
module ::CascadingConfiguration::Array::ObjectConfigurationMockModuleExtended
|
632
|
-
extend CascadingConfiguration::Array
|
633
|
-
# => singleton gets attr_configuration and configurations
|
634
|
-
respond_to?( :attr_object_configuration_array ).should == true
|
635
|
-
attr_object_configuration_array :configuration_setting
|
636
|
-
respond_to?( :configuration_setting ).should == true
|
637
|
-
configuration_setting.should == []
|
638
|
-
configuration_setting.push( :a_configuration )
|
639
|
-
configuration_setting.should == [ :a_configuration ]
|
640
|
-
instance_methods.include?( :configuration_setting ).should == false
|
641
|
-
instance_variables.empty?.should == true
|
642
|
-
# => including modules and classes get nothing
|
643
|
-
module SubmoduleIncluding
|
644
|
-
include CascadingConfiguration::Array::ObjectConfigurationMockModuleExtended
|
645
|
-
instance_methods.include?( :configuration_setting ).should == false
|
646
|
-
respond_to?( :configuration_setting ).should == false
|
647
|
-
instance_variables.empty?.should == true
|
648
|
-
end
|
649
|
-
# => extending modules and classes get nothing
|
650
|
-
module SubmoduleExtending
|
651
|
-
extend CascadingConfiguration::Array::ObjectConfigurationMockModuleExtended
|
652
|
-
instance_methods.include?( :configuration_setting ).should == false
|
653
|
-
respond_to?( :configuration_setting ).should == false
|
654
|
-
instance_variables.empty?.should == true
|
655
|
-
end
|
656
|
-
# => instances of including and extending classes get nothing
|
657
|
-
class ClassIncluding
|
658
|
-
include CascadingConfiguration::Array::ObjectConfigurationMockModuleExtended
|
659
|
-
instance_methods.include?( :configuration_setting ).should == false
|
660
|
-
respond_to?( :configuration_setting ).should == false
|
661
|
-
instance_variables.empty?.should == true
|
662
|
-
end
|
663
|
-
class ClassExtending
|
664
|
-
extend CascadingConfiguration::Array::ObjectConfigurationMockModuleExtended
|
665
|
-
instance_methods.include?( :configuration_setting ).should == false
|
666
|
-
respond_to?( :configuration_setting ).should == false
|
667
|
-
instance_variables.empty?.should == true
|
668
|
-
end
|
669
|
-
end
|
670
|
-
|
671
|
-
# * module included with setting
|
672
|
-
module ::CascadingConfiguration::Array::ObjectConfigurationMockModuleIncluded
|
673
|
-
include CascadingConfiguration::Array
|
674
|
-
# => singleton gets attr_configuration and configurations
|
675
|
-
respond_to?( :attr_object_configuration_array ).should == true
|
676
|
-
attr_object_configuration_array :configuration_setting
|
677
|
-
respond_to?( :configuration_setting ).should == true
|
678
|
-
configuration_setting.should == []
|
679
|
-
configuration_setting.push( :a_configuration )
|
680
|
-
configuration_setting.should == [ :a_configuration ]
|
681
|
-
instance_methods.include?( :configuration_setting ).should == false
|
682
|
-
instance_variables.empty?.should == true
|
683
|
-
# => including modules and classes get attr_configuration and configurations
|
684
|
-
module SubmoduleIncluding
|
685
|
-
include CascadingConfiguration::Array::ObjectConfigurationMockModuleIncluded
|
686
|
-
instance_methods.include?( :configuration_setting ).should == false
|
687
|
-
respond_to?( :configuration_setting ).should == false
|
688
|
-
instance_methods.include?( :configuration_setting ).should == false
|
689
|
-
instance_variables.empty?.should == true
|
690
|
-
end
|
691
|
-
# => extending modules and classes get attr_configuration and configurations
|
692
|
-
module SubmoduleExtending
|
693
|
-
extend CascadingConfiguration::Array::ObjectConfigurationMockModuleIncluded
|
694
|
-
# if we're extended then we want to use the eigenclass ancestor chain
|
695
|
-
# - the first ancestor will be the extending module
|
696
|
-
# - the rest of the ancestors will be the extending module's include chain
|
697
|
-
respond_to?( :configuration_setting ).should == false
|
698
|
-
instance_methods.include?( :configuration_setting ).should == false
|
699
|
-
instance_variables.empty?.should == true
|
700
|
-
end
|
701
|
-
# => instances of including classes get configurations
|
702
|
-
class ClassIncluding
|
703
|
-
include CascadingConfiguration::Array::ObjectConfigurationMockModuleIncluded
|
704
|
-
instance_methods.include?( :configuration_setting ).should == false
|
705
|
-
respond_to?( :configuration_setting ).should == false
|
706
|
-
instance_variables.empty?.should == true
|
707
|
-
end
|
708
|
-
setting_class_including_instance = ClassIncluding.new
|
709
|
-
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
710
|
-
setting_class_including_instance.instance_variables.empty?.should == true
|
711
|
-
# => instances of extending classes get nothing
|
712
|
-
class ClassExtending
|
713
|
-
extend CascadingConfiguration::Array::ObjectConfigurationMockModuleIncluded
|
714
|
-
instance_methods.include?( :configuration_setting ).should == false
|
715
|
-
respond_to?( :configuration_setting ).should == false
|
716
|
-
instance_variables.empty?.should == true
|
717
|
-
end
|
718
|
-
setting_class_including_instance = ClassExtending.new
|
719
|
-
setting_class_including_instance.respond_to?( :configuration_setting ).should == false
|
720
|
-
setting_class_including_instance.instance_variables.empty?.should == true
|
721
|
-
end
|
722
|
-
|
723
|
-
class CascadingConfiguration::Array::ObjectConfigurationMockClass
|
724
|
-
include CascadingConfiguration::Array::ObjectConfigurationMockModuleIncluded::SubmoduleIncluding
|
725
|
-
instance_methods.include?( :configuration_setting ).should == false
|
726
|
-
respond_to?( :configuration_setting ).should == false
|
727
|
-
instance_variables.empty?.should == true
|
728
|
-
end
|
729
|
-
object_instance_one = CascadingConfiguration::Array::ObjectConfigurationMockClass.new
|
730
|
-
object_instance_one.respond_to?( :configuration_setting ).should == false
|
731
|
-
object_instance_one.instance_variables.empty?.should == true
|
732
|
-
class CascadingConfiguration::Array::ObjectConfigurationMockClassSub1 < CascadingConfiguration::Array::ObjectConfigurationMockClass
|
733
|
-
instance_methods.include?( :configuration_setting ).should == false
|
734
|
-
respond_to?( :configuration_setting ).should == false
|
735
|
-
instance_variables.empty?.should == true
|
736
|
-
end
|
737
|
-
object_instance_two = CascadingConfiguration::Array::ObjectConfigurationMockClassSub1.new
|
738
|
-
object_instance_two.respond_to?( :configuration_setting ).should == false
|
739
|
-
object_instance_two.instance_variables.empty?.should == true
|
740
|
-
class CascadingConfiguration::Array::ObjectConfigurationMockClassSub2 < CascadingConfiguration::Array::ObjectConfigurationMockClassSub1
|
741
|
-
instance_methods.include?( :configuration_setting ).should == false
|
742
|
-
respond_to?( :configuration_setting ).should == false
|
743
|
-
instance_variables.empty?.should == true
|
744
|
-
end
|
745
|
-
|
746
|
-
end
|
747
|
-
|
748
|
-
#########################################
|
749
|
-
# attr_configuration_array with hooks #
|
750
|
-
#########################################
|
751
|
-
|
752
|
-
it 'can define a configuration array with hooks' do
|
753
|
-
module ::CascadingConfiguration::Array::HooksMock
|
754
|
-
include ::CascadingConfiguration::Array
|
755
|
-
module ExtensionModule
|
756
|
-
def push( arg )
|
757
|
-
super( 2 )
|
758
|
-
end
|
759
|
-
end
|
760
|
-
attr_configuration_array :configuration_setting, ExtensionModule
|
761
|
-
configuration_setting.push( 1 )
|
762
|
-
configuration_setting[ 0 ].should == 2
|
763
|
-
attr_configuration_array :other_configuration_setting do
|
764
|
-
def push( arg )
|
765
|
-
super( 2 )
|
766
|
-
end
|
767
|
-
end
|
768
|
-
other_configuration_setting.push( 1 )
|
769
|
-
other_configuration_setting[ 0 ].should == 2
|
770
|
-
end
|
771
|
-
end
|
772
|
-
|
773
|
-
end
|