cascading-configuration-hash 2.1.6 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,46 @@
1
+ == 7/13/2011
2
+
3
+ Initial release.
4
+
5
+ == 7/14/2011
6
+
7
+ * CascadingConfiguration::
8
+ - ConfigurationHash renamed to LocalConfigurationHash
9
+ - CascadingCompositeHash renamed to CompositingHash
10
+ - ConfigurationSettingsHash renamed to Hash
11
+
12
+ == 8/8/2011
13
+
14
+ Added :attr_object_configuration_hash and :attr_instance_configuration_hash and refined :attr_local_configuration_hash.
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
+ == 3/4/2012
33
+
34
+ Significantly reduced redundant code.
35
+ Added accessor-utilities support, meaning now configurations can be named with ? at the end, which creates :method? and :method=".
36
+
37
+ == 3/18/2012
38
+
39
+ Method definition moved to ::CascadingConfiguration::Methods based on configuration method. Less source code to maintain, and easier to add further modules!
40
+ CompositingArray moved to independent gem (compositing-array).
41
+ Added compositing object extension support - pass in a module or use a block to define a module or both.
42
+ Removed compositing proc support. Replaced by object extension support.
43
+
44
+ == 6/18/2012
45
+
46
+ Merged into cascading-configuration.
data/README.md CHANGED
@@ -4,195 +4,16 @@ http://rubygems.org/gems/cascading-configuration-hash
4
4
 
5
5
  # Description #
6
6
 
7
- Adds methods for cascading configuration hashes. Support package for cascading-configuration.
7
+ Now just a thin wrapper for cascading-configuration.
8
8
 
9
9
  # Summary #
10
10
 
11
- Cascading configuration methods for hashes, which returns the appropriate lowest accumulated value. Configuration inheritance can cascade through modules, classes, and to instances.
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_hash ##
42
-
43
- :attr_configuration_array provides inheritable hash configurations that cascade downward. A composite hash 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
- Define initial configuration in a module or class:
48
-
49
- ```ruby
50
- module SomeModule
51
-
52
- include CascadingConfiguration::Hash
53
-
54
- attr_configuration_hash :some_hash_setting
55
-
56
- some_hash_setting # => nil
57
-
58
- some_hash_setting[ :some_setting ] = :some_value
59
-
60
- some_hash_setting[ :some_setting ] # => :some_value
61
-
62
- end
63
- ```
64
-
65
- Include initial module in a module or class:
66
-
67
- ```ruby
68
- class SomeClass
69
-
70
- include SomeModule
71
-
72
- some_hash_setting[ :some_setting ] # => :some_value
73
-
74
- self.some_hash_setting.replace( :some_other_setting => :some_other_value )
75
-
76
- some_hash_setting # => { :some_other_setting => :some_other_value }
77
-
78
- end
79
- ```
80
-
81
- And it cascades to instances:
82
-
83
- ```ruby
84
- instance = SomeClass.new
85
-
86
- instance.some_hash_setting.should == { :some_other_setting => :some_other_value }
87
-
88
- instance.some_hash_setting.delete( :some_other_setting )
89
-
90
- instance.some_hash_setting.should == {}
91
- ```
92
-
93
- ### :attr_module_configuration_hash, :attr_class_configuration_hash ###
94
-
95
- :attr_class_configuration_hash works like :attr_configuration_hash but does not cascade to instances.
96
-
97
- Define initial configuration in a module or class:
98
-
99
- ```ruby
100
- module SomeModule
101
-
102
- include CascadingConfiguration::Hash
103
-
104
- attr_class_configuration_hash :some_hash_setting
105
-
106
- some_hash_setting # => nil
107
-
108
- some_hash_setting[ :some_setting ] = :some_value
109
-
110
- some_hash_setting[ :some_setting ] # => :some_value
111
-
112
- end
113
- ```
114
-
115
- Include initial module in a module or class:
116
-
117
- ```ruby
118
- class SomeClass
119
-
120
- include SomeModule
121
-
122
- some_hash_setting[ :some_setting ] # => :some_value
123
-
124
- self.some_hash_setting.replace( :some_other_setting => :some_other_value )
125
-
126
- some_hash_setting # => { :some_other_setting => :some_other_value }
127
-
128
- end
129
- ```
130
-
131
- And it does not cascade to instances:
132
-
133
- ```ruby
134
- instance = SomeClass.new
135
-
136
- instance.respond_to?( :some_hash_setting ).should == false
137
- ```
138
-
139
- ### :attr_local_configuration_hash ###
140
-
141
- :attr_local_configuration_hash works like :attr_configuration_hash 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).
142
-
143
- Define initial configuration in a module or class:
144
-
145
- ```ruby
146
- module SomeModule
147
-
148
- include CascadingConfiguration::Hash
149
-
150
- attr_class_configuration_hash :some_hash_setting
151
-
152
- some_hash_setting # => nil
153
-
154
- some_hash_setting[ :some_setting ] = :some_value
155
-
156
- some_hash_setting[ :some_setting ] # => :some_value
157
-
158
- end
159
- ```
160
-
161
- Include initial module in a module or class:
162
-
163
- ```ruby
164
- class SomeClass
165
-
166
- include SomeModule
167
-
168
- respond_to?( :some_hash_setting ).should == false
169
-
170
- end
171
- ```
172
-
173
- ## Additional Functionality ##
174
-
175
- Cascading-configuration also provides several other convenience functions.
176
-
177
- ### Method Redefinition ###
178
-
179
- Any declared configuration is defined in order to support locally redefining the method and accessing the original by calling super.
180
-
181
- ```ruby
182
- module SomeModule
183
-
184
- include CascadingConfiguration
185
-
186
- attr_configuration :some_array_setting
187
-
188
- def some_array_setting=( value )
189
- puts 'Replacing configuration array!'
190
- super
191
- end
192
-
193
- end
194
- ```
195
-
196
17
  # License #
197
18
 
198
19
  (The MIT License)
@@ -4,31 +4,15 @@ http://rubygems.org/gems/cascading-configuration-hash
4
4
 
5
5
  == Description
6
6
 
7
- Adds methods for cascading configuration hashes. Support package for cascading-configuration.
7
+ Now just a thin wrapper for cascading-configuration.
8
8
 
9
9
  == Summary
10
10
 
11
- Cascading configuration methods for hashes, which returns the appropriate lowest accumulated value. Configuration inheritance can cascade through modules, classes, and to instances.
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_hash
16
-
17
- :attr_configuration_array provides inheritable hash configurations that cascade downward. A composite hash 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
- :attr_class_configuration_hash works like :attr_configuration_hash but does not cascade to instances.
22
-
23
- :attr_local_configuration_hash works like :attr_configuration_hash 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.
24
12
 
25
13
  == Install
26
14
 
27
- * sudo gem install cascading-configuration-hash
28
-
29
- == Usage
30
-
31
- See README.md
15
+ * sudo gem install cascading-configuration
32
16
 
33
17
  == License
34
18
 
@@ -1,15 +1,2 @@
1
1
 
2
- require 'compositing-hash'
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 Hash
12
- end
13
- end
14
-
15
- require_relative 'cascading-configuration-hash/CascadingConfiguration/Hash.rb'
2
+ require 'cascading-configuration'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cascading-configuration-hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.6
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-03-23 00:00:00.000000000 Z
12
+ date: 2012-06-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: cascading-configuration-variable
16
- requirement: &70157573803920 !ruby/object:Gem::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: *70157573803920
25
- description: Provides :attr_configuration_hash.
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-hash/CascadingConfiguration/Hash.rb
32
36
  - lib/cascading-configuration-hash.rb
33
- - spec/CascadingConfiguration/Hash_spec.rb
34
37
  - README.md
35
38
  - README.rdoc
36
- homepage: http://rubygems.org/gems/cascading-configuration-hash
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-hash
56
- rubygems_version: 1.8.11
60
+ rubygems_version: 1.8.23
57
61
  signing_key:
58
62
  specification_version: 3
59
- summary: Support package for cascading-configuration.
63
+ summary: Deprecated.
60
64
  test_files: []
65
+ has_rdoc:
@@ -1,29 +0,0 @@
1
-
2
- module ::CascadingConfiguration::Hash
3
-
4
- # Configuration modules for storage of settings hashes
5
- include ::CascadingConfiguration::Inheritance
6
-
7
- #############################################
8
- # attr_configuration_unique_hash #
9
- # attr_module_configuration_unique_hash #
10
- # attr_local_configuration_unique_hash #
11
- # attr_object_configuration_unique_hash #
12
- # attr_instance_configuration_unique_hash #
13
- #############################################
14
-
15
- def attr_configuration_unique_hash( *configuration_names, & define_block ) ;; end
16
- def attr_module_configuration_unique_hash( *configuration_names, & define_block ) ;; end
17
- def attr_class_configuration_unique_hash( *configuration_names, & define_block ) ;; end
18
- def attr_local_configuration_unique_hash( *configuration_names, & define_block ) ;; end
19
- def attr_object_configuration_unique_hash( *configuration_names, & define_block ) ;; end
20
- def attr_instance_configuration_unique_hash( *configuration_names, & define_block ) ;; end
21
-
22
- ccd = ::CascadingConfiguration::Definition
23
-
24
- ccd.declare_compositing_configuration_object( self, :hash, ::CompositingHash )
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,838 +0,0 @@
1
-
2
- if $__cascading_configuration__spec__development
3
- require_relative '../../lib/cascading-configuration-hash.rb'
4
- else
5
- require 'cascading-configuration-hash'
6
- end
7
-
8
- describe CascadingConfiguration::Hash do
9
-
10
- #############################
11
- # attr_configuration_hash #
12
- #############################
13
-
14
- it 'can define a configuration hash, 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::Hash::ConfigurationMockModuleExtended
29
- extend CascadingConfiguration::Hash
30
- # => singleton gets attr_configuration and configurations
31
- respond_to?( :attr_configuration_hash ).should == true
32
- attr_configuration_hash :configuration_setting
33
- respond_to?( :configuration_setting ).should == true
34
- configuration_setting.should == {}
35
- self.configuration_setting[ :a_configuration ] = :some_value
36
- configuration_setting.should == { :a_configuration => :some_value }
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::Hash::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::Hash::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::Hash::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::Hash::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::Hash::ConfigurationMockModuleIncluded
70
- include CascadingConfiguration::Hash
71
- # => singleton gets attr_configuration and configurations
72
- respond_to?( :attr_configuration_hash ).should == true
73
- attr_configuration_hash :configuration_setting
74
- respond_to?( :configuration_setting ).should == true
75
- configuration_setting.should == {}
76
- self.configuration_setting[ :a_configuration ] = :some_value
77
- configuration_setting.should == { :a_configuration => :some_value }
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::Hash::ConfigurationMockModuleIncluded
83
- instance_methods.include?( :configuration_setting ).should == true
84
- respond_to?( :configuration_setting ).should == true
85
- configuration_setting.should == { :a_configuration => :some_value }
86
- configuration_setting[ :other_setting ] = :some_value
87
- configuration_setting.should == { :a_configuration => :some_value,
88
- :other_setting => :some_value }
89
- configuration_setting.delete( :other_setting ).should == :some_value
90
- configuration_setting.should == { :a_configuration => :some_value }
91
- instance_variables.empty?.should == true
92
- end
93
- # => extending modules and classes get attr_configuration and configurations
94
- module SubmoduleExtending
95
- extend CascadingConfiguration::Hash::ConfigurationMockModuleIncluded
96
- # if we're extended then we want to use the eigenclass ancestor chain
97
- # - the first ancestor will be the extending module
98
- # - the rest of the ancestors will be the extending module's include chain
99
- respond_to?( :configuration_setting ).should == true
100
- configuration_setting.should == { :a_configuration => :some_value }
101
- configuration_setting[ :other_setting ] = :some_value
102
- configuration_setting.should == { :a_configuration => :some_value,
103
- :other_setting => :some_value }
104
- configuration_setting.delete( :other_setting ).should == :some_value
105
- configuration_setting.should == { :a_configuration => :some_value }
106
- instance_methods.include?( :configuration_setting ).should == false
107
- instance_variables.empty?.should == true
108
- end
109
- # => instances of including classes get configurations
110
- class ClassIncluding
111
- include CascadingConfiguration::Hash::ConfigurationMockModuleIncluded
112
- instance_methods.include?( :configuration_setting ).should == true
113
- respond_to?( :configuration_setting ).should == true
114
- configuration_setting.should == { :a_configuration => :some_value }
115
- configuration_setting[ :other_setting ] = :some_value
116
- configuration_setting.should == { :a_configuration => :some_value,
117
- :other_setting => :some_value }
118
- configuration_setting.delete( :other_setting ).should == :some_value
119
- configuration_setting.should == { :a_configuration => :some_value }
120
- instance_variables.empty?.should == true
121
- end
122
- setting_class_including_instance = ClassIncluding.new
123
- setting_class_including_instance.respond_to?( :configuration_setting ).should == true
124
- setting_class_including_instance.configuration_setting.should == { :a_configuration => :some_value }
125
- setting_class_including_instance.configuration_setting.delete( :a_configuration )
126
- setting_class_including_instance.instance_variables.empty?.should == true
127
- class ClassExtending
128
- extend CascadingConfiguration::Hash::ConfigurationMockModuleIncluded
129
- respond_to?( :configuration_setting ).should == true
130
- configuration_setting.should == { :a_configuration => :some_value }
131
- configuration_setting[ :other_setting ] = :some_value
132
- configuration_setting.should == { :a_configuration => :some_value,
133
- :other_setting => :some_value }
134
- configuration_setting.delete( :other_setting ).should == :some_value
135
- configuration_setting.should == { :a_configuration => :some_value }
136
- instance_variables.empty?.should == true
137
- end
138
- setting_class_including_instance = ClassExtending.new
139
- setting_class_including_instance.respond_to?( :configuration_setting ).should == false
140
- setting_class_including_instance.instance_variables.empty?.should == true
141
- end
142
-
143
- class CascadingConfiguration::Hash::ConfigurationMockClass
144
- include CascadingConfiguration::Hash::ConfigurationMockModuleIncluded::SubmoduleIncluding
145
- configuration_setting.should == { :a_configuration => :some_value }
146
- configuration_setting[ :other_setting ] = :some_value
147
- configuration_setting.should == { :a_configuration => :some_value,
148
- :other_setting => :some_value }
149
- configuration_setting.delete( :other_setting ).should == :some_value
150
- configuration_setting.should == { :a_configuration => :some_value }
151
- instance_variables.empty?.should == true
152
- end
153
-
154
- object_instance_one = CascadingConfiguration::Hash::ConfigurationMockClass.new
155
- object_instance_one.configuration_setting.should == { :a_configuration => :some_value }
156
- object_instance_one.configuration_setting[ :some_other_configuration ] = :some_value
157
- object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
158
- :some_other_configuration => :some_value }
159
- object_instance_one.instance_variables.empty?.should == true
160
-
161
- class CascadingConfiguration::Hash::ConfigurationMockClassSub1 < CascadingConfiguration::Hash::ConfigurationMockClass
162
- configuration_setting.should == { :a_configuration => :some_value }
163
- self.configuration_setting[ :another_configuration ] = :some_value
164
- configuration_setting.should == { :a_configuration => :some_value,
165
- :another_configuration => :some_value }
166
- instance_variables.empty?.should == true
167
- end
168
-
169
- object_instance_two = CascadingConfiguration::Hash::ConfigurationMockClassSub1.new
170
- object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
171
- :another_configuration => :some_value }
172
- object_instance_two.configuration_setting[ :some_other_configuration ] = :some_value
173
- object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
174
- :another_configuration => :some_value,
175
- :some_other_configuration => :some_value }
176
- object_instance_two.instance_variables.empty?.should == true
177
-
178
- # change ancestor setting
179
- CascadingConfiguration::Hash::ConfigurationMockClass.configuration_setting[ :a_yet_unused_configuration ] = :some_value
180
- CascadingConfiguration::Hash::ConfigurationMockClass.configuration_setting.should == { :a_configuration => :some_value,
181
- :a_yet_unused_configuration => :some_value }
182
- object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
183
- :a_yet_unused_configuration => :some_value,
184
- :some_other_configuration => :some_value }
185
- CascadingConfiguration::Hash::ConfigurationMockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
186
- :a_yet_unused_configuration => :some_value,
187
- :another_configuration => :some_value }
188
- object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
189
- :a_yet_unused_configuration => :some_value,
190
- :another_configuration => :some_value,
191
- :some_other_configuration => :some_value }
192
-
193
- # freeze ancestor setting
194
- object_instance_one.configuration_setting.freeze!
195
- object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
196
- :a_yet_unused_configuration => :some_value,
197
- :some_other_configuration => :some_value }
198
- CascadingConfiguration::Hash::ConfigurationMockClassSub1.configuration_setting.freeze!
199
- CascadingConfiguration::Hash::ConfigurationMockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
200
- :a_yet_unused_configuration => :some_value,
201
- :another_configuration => :some_value }
202
- CascadingConfiguration::Hash::ConfigurationMockClass.configuration_setting[ :non_cascading_configuration ] = :some_value
203
- CascadingConfiguration::Hash::ConfigurationMockClass.configuration_setting.should == { :a_configuration => :some_value,
204
- :a_yet_unused_configuration => :some_value,
205
- :non_cascading_configuration => :some_value }
206
- object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
207
- :a_yet_unused_configuration => :some_value,
208
- :some_other_configuration => :some_value }
209
- CascadingConfiguration::Hash::ConfigurationMockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
210
- :a_yet_unused_configuration => :some_value,
211
- :another_configuration => :some_value }
212
- object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
213
- :a_yet_unused_configuration => :some_value,
214
- :another_configuration => :some_value,
215
- :some_other_configuration => :some_value }
216
-
217
- module ::CascadingConfiguration::Hash::ConfigurationMockModule
218
- include CascadingConfiguration::Hash
219
- attr_configuration_hash :some_hash do
220
- def merge!( other_hash )
221
- other_hash.each do |key, foreign_value|
222
- if existing_value = self[ key ]
223
- self[ key ] = foreign_value - existing_value
224
- else
225
- self[ key ] = foreign_value
226
- end
227
- end
228
- end
229
- end
230
- self.some_hash = { :one => 1, :two => 2 }
231
- self.some_hash.should == { :one => 1, :two => 2 }
232
- end
233
-
234
- module ::CascadingConfiguration::Hash::ConfigurationMockModule2
235
- include CascadingConfiguration::Hash::ConfigurationMockModule
236
- self.some_hash.should == { :one => 1, :two => 2 }
237
- self.some_hash.merge!( { :one => 1, :two => 2 } )
238
- self.some_hash.should == { :one => 0, :two => 0 }
239
- end
240
-
241
- end
242
-
243
- ####################################
244
- # attr_module_configuration_hash #
245
- # attr_class_configuration_hash #
246
- ####################################
247
-
248
- it 'can define a class configuration hash, which will not cascade to instances' do
249
-
250
- # possibilities:
251
- # * module extended with setting
252
- # => singleton gets attr_configuration and configurations
253
- # => including modules and classes get nothing
254
- # => extending modules and classes get nothing
255
- # => instances of including and extending classes get nothing
256
- # * module included with setting
257
- # => singleton gets attr_configuration and configurations
258
- # => including modules and classes get attr_configuration and configurations
259
- # => instances of including classes get configurations
260
- # => extending modules and classes get attr_configuration and configurations
261
- # => instances of extending classes get nothing
262
- module ::CascadingConfiguration::Hash::ClassConfigurationMockModuleExtended
263
- extend CascadingConfiguration::Hash
264
- # => singleton gets attr_configuration and configurations
265
- respond_to?( :attr_module_configuration_hash ).should == true
266
- method( :attr_module_configuration_hash ).should == method( :attr_class_configuration_hash )
267
- attr_module_configuration_hash :configuration_setting
268
- respond_to?( :configuration_setting ).should == true
269
- configuration_setting.should == {}
270
- self.configuration_setting[ :a_configuration ] = :some_value
271
- configuration_setting.should == { :a_configuration => :some_value }
272
- instance_methods.include?( :configuration_setting ).should == false
273
- instance_variables.empty?.should == true
274
- # => including modules and classes get nothing
275
- module SubmoduleIncluding
276
- include CascadingConfiguration::Hash::ClassConfigurationMockModuleExtended
277
- instance_methods.include?( :configuration_setting ).should == false
278
- respond_to?( :configuration_setting ).should == false
279
- instance_variables.empty?.should == true
280
- end
281
- # => extending modules and classes get nothing
282
- module SubmoduleExtending
283
- extend CascadingConfiguration::Hash::ClassConfigurationMockModuleExtended
284
- instance_methods.include?( :configuration_setting ).should == false
285
- respond_to?( :configuration_setting ).should == false
286
- instance_variables.empty?.should == true
287
- end
288
- # => instances of including and extending classes get nothing
289
- class ClassIncluding
290
- include CascadingConfiguration::Hash::ClassConfigurationMockModuleExtended
291
- instance_methods.include?( :configuration_setting ).should == false
292
- respond_to?( :configuration_setting ).should == false
293
- instance_variables.empty?.should == true
294
- end
295
- class ClassExtending
296
- extend CascadingConfiguration::Hash::ClassConfigurationMockModuleExtended
297
- instance_methods.include?( :configuration_setting ).should == false
298
- respond_to?( :configuration_setting ).should == false
299
- instance_variables.empty?.should == true
300
- end
301
- end
302
-
303
- # * module included with setting
304
- module ::CascadingConfiguration::Hash::ClassConfigurationMockModuleIncluded
305
- include CascadingConfiguration::Hash
306
- # => singleton gets attr_configuration and configurations
307
- respond_to?( :attr_module_configuration_hash ).should == true
308
- attr_module_configuration_hash :configuration_setting
309
- respond_to?( :configuration_setting ).should == true
310
- configuration_setting.should == {}
311
- self.configuration_setting[ :a_configuration ] = :some_value
312
- configuration_setting.should == { :a_configuration => :some_value }
313
- instance_methods.include?( :configuration_setting ).should == false
314
- instance_variables.empty?.should == true
315
- # => including modules and classes get attr_configuration and configurations
316
- module SubmoduleIncluding
317
- include CascadingConfiguration::Hash::ClassConfigurationMockModuleIncluded
318
- instance_methods.include?( :configuration_setting ).should == false
319
- respond_to?( :configuration_setting ).should == true
320
- configuration_setting.should == { :a_configuration => :some_value }
321
- configuration_setting[ :other_setting ] = :some_value
322
- configuration_setting.should == { :a_configuration => :some_value,
323
- :other_setting => :some_value }
324
- configuration_setting.delete( :other_setting ).should == :some_value
325
- configuration_setting.should == { :a_configuration => :some_value }
326
- instance_variables.empty?.should == true
327
- end
328
- # => extending modules and classes get attr_configuration and configurations
329
- module SubmoduleExtending
330
- extend CascadingConfiguration::Hash::ClassConfigurationMockModuleIncluded
331
- # if we're extended then we want to use the eigenclass ancestor chain
332
- # - the first ancestor will be the extending module
333
- # - the rest of the ancestors will be the extending module's include chain
334
- respond_to?( :configuration_setting ).should == true
335
- configuration_setting.should == { :a_configuration => :some_value }
336
- configuration_setting[ :other_setting ] = :some_value
337
- configuration_setting.should == { :a_configuration => :some_value,
338
- :other_setting => :some_value }
339
- configuration_setting.delete( :other_setting ).should == :some_value
340
- configuration_setting.should == { :a_configuration => :some_value }
341
- instance_methods.include?( :configuration_setting ).should == false
342
- instance_variables.empty?.should == true
343
- end
344
- # => instances of including classes get configurations
345
- class ClassIncluding
346
- include CascadingConfiguration::Hash::ClassConfigurationMockModuleIncluded
347
- instance_methods.include?( :configuration_setting ).should == false
348
- respond_to?( :configuration_setting ).should == true
349
- configuration_setting.should == { :a_configuration => :some_value }
350
- configuration_setting[ :other_setting ] = :some_value
351
- configuration_setting.should == { :a_configuration => :some_value,
352
- :other_setting => :some_value }
353
- configuration_setting.delete( :other_setting ).should == :some_value
354
- configuration_setting.should == { :a_configuration => :some_value }
355
- instance_variables.empty?.should == true
356
- end
357
- setting_class_including_instance = ClassIncluding.new
358
- setting_class_including_instance.respond_to?( :configuration_setting ).should == false
359
- setting_class_including_instance.instance_variables.empty?.should == true
360
- class ClassExtending
361
- extend CascadingConfiguration::Hash::ClassConfigurationMockModuleIncluded
362
- respond_to?( :configuration_setting ).should == true
363
- instance_methods.include?( :configuration_setting ).should == false
364
- configuration_setting.should == { :a_configuration => :some_value }
365
- configuration_setting[ :other_setting ] = :some_value
366
- configuration_setting.should == { :a_configuration => :some_value,
367
- :other_setting => :some_value }
368
- configuration_setting.delete( :other_setting ).should == :some_value
369
- configuration_setting.should == { :a_configuration => :some_value }
370
- instance_variables.empty?.should == true
371
- end
372
- setting_class_including_instance = ClassExtending.new
373
- setting_class_including_instance.respond_to?( :configuration_setting ).should == false
374
- setting_class_including_instance.instance_variables.empty?.should == true
375
- end
376
-
377
- class CascadingConfiguration::Hash::ClassConfigurationMockClass
378
- include CascadingConfiguration::Hash::ClassConfigurationMockModuleIncluded::SubmoduleIncluding
379
- respond_to?( :configuration_setting ).should == true
380
- instance_methods.include?( :configuration_setting ).should == false
381
- configuration_setting.should == { :a_configuration => :some_value }
382
- configuration_setting[ :other_setting ] = :some_value
383
- configuration_setting.should == { :a_configuration => :some_value,
384
- :other_setting => :some_value }
385
- configuration_setting.delete( :other_setting ).should == :some_value
386
- configuration_setting.should == { :a_configuration => :some_value }
387
- instance_variables.empty?.should == true
388
- end
389
-
390
- object_instance_one = CascadingConfiguration::Hash::ClassConfigurationMockClass.new
391
- object_instance_one.respond_to?( :configuration_setting ).should == false
392
- object_instance_one.instance_variables.empty?.should == true
393
-
394
- class CascadingConfiguration::Hash::ClassConfigurationMockClassSub1 < CascadingConfiguration::Hash::ClassConfigurationMockClass
395
- respond_to?( :configuration_setting ).should == true
396
- instance_methods.include?( :configuration_setting ).should == false
397
- configuration_setting.should == { :a_configuration => :some_value }
398
- self.configuration_setting[ :another_configuration ] = :some_value
399
- configuration_setting.should == { :a_configuration => :some_value,
400
- :another_configuration => :some_value }
401
- instance_variables.empty?.should == true
402
- end
403
-
404
- object_instance_two = CascadingConfiguration::Hash::ClassConfigurationMockClassSub1.new
405
- object_instance_two.respond_to?( :configuration_setting ).should == false
406
-
407
- # change ancestor setting
408
- CascadingConfiguration::Hash::ClassConfigurationMockClass.configuration_setting[ :a_yet_unused_configuration ] = :some_value
409
- CascadingConfiguration::Hash::ClassConfigurationMockClass.configuration_setting.should == { :a_configuration => :some_value,
410
- :a_yet_unused_configuration => :some_value }
411
- CascadingConfiguration::Hash::ClassConfigurationMockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
412
- :a_yet_unused_configuration => :some_value,
413
- :another_configuration => :some_value }
414
-
415
- # freeze ancestor setting
416
- CascadingConfiguration::Hash::ClassConfigurationMockClassSub1.configuration_setting.freeze!
417
- CascadingConfiguration::Hash::ClassConfigurationMockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
418
- :a_yet_unused_configuration => :some_value,
419
- :another_configuration => :some_value }
420
- CascadingConfiguration::Hash::ClassConfigurationMockClass.configuration_setting[ :non_cascading_configuration ] = :some_value
421
- CascadingConfiguration::Hash::ClassConfigurationMockClass.configuration_setting.should == { :a_configuration => :some_value,
422
- :a_yet_unused_configuration => :some_value,
423
- :non_cascading_configuration => :some_value }
424
- CascadingConfiguration::Hash::ClassConfigurationMockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
425
- :a_yet_unused_configuration => :some_value,
426
- :another_configuration => :some_value }
427
-
428
- module ::CascadingConfiguration::Hash::ClassConfigurationMockModule
429
- include CascadingConfiguration::Hash
430
- attr_configuration_hash :some_hash do
431
- def merge!( other_hash )
432
- other_hash.each do |key, foreign_value|
433
- if existing_value = self[ key ]
434
- self[ key ] = foreign_value - existing_value
435
- else
436
- self[ key ] = foreign_value
437
- end
438
- end
439
- end
440
- end
441
- self.some_hash = { :one => 1, :two => 2 }
442
- self.some_hash.should == { :one => 1, :two => 2 }
443
- end
444
-
445
- module ::CascadingConfiguration::Hash::ClassConfigurationMockModule2
446
- include CascadingConfiguration::Hash::ClassConfigurationMockModule
447
- self.some_hash.should == { :one => 1, :two => 2 }
448
- self.some_hash.merge!( { :one => 1, :two => 2 } )
449
- self.some_hash.should == { :one => 0, :two => 0 }
450
- end
451
-
452
- end
453
-
454
- ###################################
455
- # attr_local_configuration_hash #
456
- ###################################
457
-
458
- it 'can define a local configuration hash, which will not cascade' do
459
-
460
- # possibilities:
461
- # * module extended with setting
462
- # => singleton gets attr_configuration and configurations
463
- # => including modules and classes get nothing
464
- # => extending modules and classes get nothing
465
- # => instances of including and extending classes get nothing
466
- # * module included with setting
467
- # => singleton gets attr_configuration and configurations
468
- # => including modules and classes get attr_configuration and configurations
469
- # => instances of including classes get configurations
470
- # => extending modules and classes get attr_configuration and configurations
471
- # => instances of extending classes get nothing
472
- module ::CascadingConfiguration::Hash::LocalConfigurationMockModuleExtended
473
- extend CascadingConfiguration::Hash
474
- # => singleton gets attr_configuration and configurations
475
- respond_to?( :attr_local_configuration_hash ).should == true
476
- attr_local_configuration_hash :configuration_setting
477
- respond_to?( :configuration_setting ).should == true
478
- configuration_setting.should == {}
479
- self.configuration_setting[ :a_configuration ] = :some_value
480
- configuration_setting.should == { :a_configuration => :some_value }
481
- instance_methods.include?( :configuration_setting ).should == false
482
- instance_variables.empty?.should == true
483
- # => including modules and classes get nothing
484
- module SubmoduleIncluding
485
- include CascadingConfiguration::Hash::LocalConfigurationMockModuleExtended
486
- instance_methods.include?( :configuration_setting ).should == false
487
- respond_to?( :configuration_setting ).should == false
488
- instance_variables.empty?.should == true
489
- end
490
- # => extending modules and classes get nothing
491
- module SubmoduleExtending
492
- extend CascadingConfiguration::Hash::LocalConfigurationMockModuleExtended
493
- instance_methods.include?( :configuration_setting ).should == false
494
- respond_to?( :configuration_setting ).should == false
495
- instance_variables.empty?.should == true
496
- end
497
- # => instances of including and extending classes get nothing
498
- class ClassIncluding
499
- include CascadingConfiguration::Hash::LocalConfigurationMockModuleExtended
500
- instance_methods.include?( :configuration_setting ).should == false
501
- respond_to?( :configuration_setting ).should == false
502
- instance_variables.empty?.should == true
503
- end
504
- class ClassExtending
505
- extend CascadingConfiguration::Hash::LocalConfigurationMockModuleExtended
506
- instance_methods.include?( :configuration_setting ).should == false
507
- respond_to?( :configuration_setting ).should == false
508
- instance_variables.empty?.should == true
509
- end
510
- end
511
-
512
- # * module included with setting
513
- module ::CascadingConfiguration::Hash::LocalConfigurationMockModuleIncluded
514
- include CascadingConfiguration::Hash
515
- # => singleton gets attr_configuration and configurations
516
- respond_to?( :attr_local_configuration_hash ).should == true
517
- attr_local_configuration_hash :configuration_setting
518
- respond_to?( :configuration_setting ).should == true
519
- configuration_setting.should == {}
520
- self.configuration_setting[ :a_configuration ] = :some_value
521
- configuration_setting.should == { :a_configuration => :some_value }
522
- instance_methods.include?( :configuration_setting ).should == true
523
- instance_variables.empty?.should == true
524
- # => including modules and classes get attr_configuration and configurations
525
- module SubmoduleIncluding
526
- include CascadingConfiguration::Hash::LocalConfigurationMockModuleIncluded
527
- instance_methods.include?( :configuration_setting ).should == true
528
- respond_to?( :configuration_setting ).should == false
529
- instance_variables.empty?.should == true
530
- end
531
- # => extending modules and classes get attr_configuration and configurations
532
- module SubmoduleExtending
533
- extend CascadingConfiguration::Hash::LocalConfigurationMockModuleIncluded
534
- # if we're extended then we want to use the eigenclass ancestor chain
535
- # - the first ancestor will be the extending module
536
- # - the rest of the ancestors will be the extending module's include chain
537
- instance_methods.include?( :configuration_setting ).should == false
538
- respond_to?( :configuration_setting ).should == true
539
- instance_variables.empty?.should == true
540
- end
541
- # => instances of including classes get configurations
542
- class ClassIncluding
543
- include CascadingConfiguration::Hash::LocalConfigurationMockModuleIncluded
544
- instance_methods.include?( :configuration_setting ).should == true
545
- respond_to?( :configuration_setting ).should == false
546
- instance_variables.empty?.should == true
547
- end
548
- setting_class_including_instance = ClassIncluding.new
549
- setting_class_including_instance.respond_to?( :configuration_setting ).should == true
550
- setting_class_including_instance.instance_variables.empty?.should == true
551
- class ClassExtending
552
- extend CascadingConfiguration::Hash::LocalConfigurationMockModuleIncluded
553
- instance_methods.include?( :configuration_setting ).should == false
554
- respond_to?( :configuration_setting ).should == true
555
- instance_variables.empty?.should == true
556
- end
557
- setting_class_including_instance = ClassExtending.new
558
- setting_class_including_instance.respond_to?( :configuration_setting ).should == false
559
- setting_class_including_instance.instance_variables.empty?.should == true
560
- end
561
-
562
- class CascadingConfiguration::Hash::LocalConfigurationMockClass
563
- include CascadingConfiguration::Hash::LocalConfigurationMockModuleIncluded::SubmoduleIncluding
564
- instance_methods.include?( :configuration_setting ).should == true
565
- respond_to?( :configuration_setting ).should == false
566
- instance_variables.empty?.should == true
567
- end
568
-
569
- object_instance_one = CascadingConfiguration::Hash::LocalConfigurationMockClass.new
570
- object_instance_one.respond_to?( :configuration_setting ).should == true
571
- object_instance_one.instance_variables.empty?.should == true
572
-
573
- class CascadingConfiguration::Hash::LocalConfigurationMockClassSub1 < CascadingConfiguration::Hash::LocalConfigurationMockClass
574
- instance_methods.include?( :configuration_setting ).should == true
575
- respond_to?( :configuration_setting ).should == false
576
- instance_variables.empty?.should == true
577
- end
578
-
579
- object_instance_two = CascadingConfiguration::Hash::LocalConfigurationMockClassSub1.new
580
- object_instance_two.respond_to?( :configuration_setting ).should == true
581
- object_instance_two.instance_variables.empty?.should == true
582
-
583
- end
584
-
585
- ######################################
586
- # attr_instance_configuration_hash #
587
- ######################################
588
-
589
- it 'can define a local configuration hash, which will not cascade' do
590
-
591
- # possibilities:
592
- # * module extended with setting
593
- # => singleton gets attr_configuration and configurations
594
- # => including modules and classes get nothing
595
- # => extending modules and classes get nothing
596
- # => instances of including and extending classes get nothing
597
- # * module included with setting
598
- # => singleton gets attr_configuration and configurations
599
- # => including modules and classes get attr_configuration and configurations
600
- # => instances of including classes get configurations
601
- # => extending modules and classes get attr_configuration and configurations
602
- # => instances of extending classes get nothing
603
- module ::CascadingConfiguration::Hash::InstanceConfigurationMockModuleExtended
604
- extend CascadingConfiguration::Hash
605
- # => singleton gets attr_configuration and configurations
606
- instance_methods.include?( :configuration_setting ).should == false
607
- instance_variables.empty?.should == true
608
- # => including modules and classes get nothing
609
- module SubmoduleIncluding
610
- include CascadingConfiguration::Hash::InstanceConfigurationMockModuleExtended
611
- instance_methods.include?( :configuration_setting ).should == false
612
- respond_to?( :configuration_setting ).should == false
613
- instance_variables.empty?.should == true
614
- end
615
- # => extending modules and classes get nothing
616
- module SubmoduleExtending
617
- extend CascadingConfiguration::Hash::InstanceConfigurationMockModuleExtended
618
- instance_methods.include?( :configuration_setting ).should == false
619
- respond_to?( :configuration_setting ).should == false
620
- instance_variables.empty?.should == true
621
- end
622
- # => instances of including and extending classes get nothing
623
- class ClassIncluding
624
- include CascadingConfiguration::Hash::InstanceConfigurationMockModuleExtended
625
- instance_methods.include?( :configuration_setting ).should == false
626
- respond_to?( :configuration_setting ).should == false
627
- instance_variables.empty?.should == true
628
- end
629
- class ClassExtending
630
- extend CascadingConfiguration::Hash::InstanceConfigurationMockModuleExtended
631
- instance_methods.include?( :configuration_setting ).should == false
632
- respond_to?( :configuration_setting ).should == false
633
- instance_variables.empty?.should == true
634
- end
635
- end
636
-
637
- # * module included with setting
638
- module ::CascadingConfiguration::Hash::InstanceConfigurationMockModuleIncluded
639
- include CascadingConfiguration::Hash
640
- # => singleton gets attr_configuration and configurations
641
- respond_to?( :attr_instance_configuration_hash ).should == true
642
- attr_instance_configuration_hash :configuration_setting
643
- respond_to?( :configuration_setting ).should == false
644
- instance_methods.include?( :configuration_setting ).should == true
645
- instance_variables.empty?.should == true
646
- # => including modules and classes get attr_configuration and configurations
647
- module SubmoduleIncluding
648
- include CascadingConfiguration::Hash::InstanceConfigurationMockModuleIncluded
649
- instance_methods.include?( :configuration_setting ).should == true
650
- respond_to?( :configuration_setting ).should == false
651
- instance_variables.empty?.should == true
652
- end
653
- # => extending modules and classes get attr_configuration and configurations
654
- module SubmoduleExtending
655
- extend CascadingConfiguration::Hash::InstanceConfigurationMockModuleIncluded
656
- # if we're extended then we want to use the eigenclass ancestor chain
657
- # - the first ancestor will be the extending module
658
- # - the rest of the ancestors will be the extending module's include chain
659
- instance_methods.include?( :configuration_setting ).should == false
660
- respond_to?( :configuration_setting ).should == true
661
- instance_variables.empty?.should == true
662
- end
663
- # => instances of including classes get configurations
664
- class ClassIncluding
665
- include CascadingConfiguration::Hash::InstanceConfigurationMockModuleIncluded
666
- instance_methods.include?( :configuration_setting ).should == true
667
- respond_to?( :configuration_setting ).should == false
668
- instance_variables.empty?.should == true
669
- end
670
- setting_class_including_instance = ClassIncluding.new
671
- setting_class_including_instance.respond_to?( :configuration_setting ).should == true
672
- setting_class_including_instance.instance_variables.empty?.should == true
673
- class ClassExtending
674
- extend CascadingConfiguration::Hash::InstanceConfigurationMockModuleIncluded
675
- instance_methods.include?( :configuration_setting ).should == false
676
- respond_to?( :configuration_setting ).should == true
677
- instance_variables.empty?.should == true
678
- end
679
- setting_class_including_instance = ClassExtending.new
680
- setting_class_including_instance.respond_to?( :configuration_setting ).should == false
681
- setting_class_including_instance.instance_variables.empty?.should == true
682
- end
683
-
684
- class CascadingConfiguration::Hash::InstanceConfigurationMockClass
685
- include CascadingConfiguration::Hash::InstanceConfigurationMockModuleIncluded::SubmoduleIncluding
686
- instance_methods.include?( :configuration_setting ).should == true
687
- respond_to?( :configuration_setting ).should == false
688
- instance_variables.empty?.should == true
689
- end
690
-
691
- object_instance_one = CascadingConfiguration::Hash::InstanceConfigurationMockClass.new
692
- object_instance_one.respond_to?( :configuration_setting ).should == true
693
- object_instance_one.instance_variables.empty?.should == true
694
-
695
- class CascadingConfiguration::Hash::InstanceConfigurationMockClassSub1 < CascadingConfiguration::Hash::InstanceConfigurationMockClass
696
- instance_methods.include?( :configuration_setting ).should == true
697
- respond_to?( :configuration_setting ).should == false
698
- instance_variables.empty?.should == true
699
- end
700
-
701
- object_instance_two = CascadingConfiguration::Hash::InstanceConfigurationMockClassSub1.new
702
- object_instance_two.respond_to?( :configuration_setting ).should == true
703
- object_instance_two.instance_variables.empty?.should == true
704
-
705
- end
706
-
707
- ####################################
708
- # attr_object_configuration_hash #
709
- ####################################
710
-
711
- it 'can define a local configuration hash, which will not cascade' do
712
-
713
- # possibilities:
714
- # * module extended with setting
715
- # => singleton gets attr_configuration and configurations
716
- # => including modules and classes get nothing
717
- # => extending modules and classes get nothing
718
- # => instances of including and extending classes get nothing
719
- # * module included with setting
720
- # => singleton gets attr_configuration and configurations
721
- # => including modules and classes get attr_configuration and configurations
722
- # => instances of including classes get configurations
723
- # => extending modules and classes get attr_configuration and configurations
724
- # => instances of extending classes get nothing
725
- module ::CascadingConfiguration::Hash::ObjectConfigurationMockModuleExtended
726
- extend CascadingConfiguration::Hash
727
- # => singleton gets attr_configuration and configurations
728
- respond_to?( :attr_object_configuration_hash ).should == true
729
- attr_object_configuration_hash :configuration_setting
730
- respond_to?( :configuration_setting ).should == true
731
- configuration_setting.should == {}
732
- self.configuration_setting[ :a_configuration ] = :some_value
733
- configuration_setting.should == { :a_configuration => :some_value }
734
- instance_methods.include?( :configuration_setting ).should == false
735
- instance_variables.empty?.should == true
736
- # => including modules and classes get nothing
737
- module SubmoduleIncluding
738
- include CascadingConfiguration::Hash::ObjectConfigurationMockModuleExtended
739
- instance_methods.include?( :configuration_setting ).should == false
740
- respond_to?( :configuration_setting ).should == false
741
- instance_variables.empty?.should == true
742
- end
743
- # => extending modules and classes get nothing
744
- module SubmoduleExtending
745
- extend CascadingConfiguration::Hash::ObjectConfigurationMockModuleExtended
746
- instance_methods.include?( :configuration_setting ).should == false
747
- respond_to?( :configuration_setting ).should == false
748
- instance_variables.empty?.should == true
749
- end
750
- # => instances of including and extending classes get nothing
751
- class ClassIncluding
752
- include CascadingConfiguration::Hash::ObjectConfigurationMockModuleExtended
753
- instance_methods.include?( :configuration_setting ).should == false
754
- respond_to?( :configuration_setting ).should == false
755
- instance_variables.empty?.should == true
756
- end
757
- class ClassExtending
758
- extend CascadingConfiguration::Hash::ObjectConfigurationMockModuleExtended
759
- instance_methods.include?( :configuration_setting ).should == false
760
- respond_to?( :configuration_setting ).should == false
761
- instance_variables.empty?.should == true
762
- end
763
- end
764
-
765
- # * module included with setting
766
- module ::CascadingConfiguration::Hash::ObjectConfigurationMockModuleIncluded
767
- include CascadingConfiguration::Hash
768
- # => singleton gets attr_configuration and configurations
769
- respond_to?( :attr_object_configuration_hash ).should == true
770
- attr_object_configuration_hash :configuration_setting
771
- respond_to?( :configuration_setting ).should == true
772
- configuration_setting.should == {}
773
- self.configuration_setting[ :a_configuration ] = :some_value
774
- configuration_setting.should == { :a_configuration => :some_value }
775
- instance_methods.include?( :configuration_setting ).should == false
776
- instance_variables.empty?.should == true
777
- # => including modules and classes get attr_configuration and configurations
778
- module SubmoduleIncluding
779
- include CascadingConfiguration::Hash::ObjectConfigurationMockModuleIncluded
780
- instance_methods.include?( :configuration_setting ).should == false
781
- respond_to?( :configuration_setting ).should == false
782
- instance_variables.empty?.should == true
783
- end
784
- # => extending modules and classes get attr_configuration and configurations
785
- module SubmoduleExtending
786
- extend CascadingConfiguration::Hash::ObjectConfigurationMockModuleIncluded
787
- # if we're extended then we want to use the eigenclass ancestor chain
788
- # - the first ancestor will be the extending module
789
- # - the rest of the ancestors will be the extending module's include chain
790
- instance_methods.include?( :configuration_setting ).should == false
791
- respond_to?( :configuration_setting ).should == false
792
- instance_variables.empty?.should == true
793
- end
794
- # => instances of including classes get configurations
795
- class ClassIncluding
796
- include CascadingConfiguration::Hash::ObjectConfigurationMockModuleIncluded
797
- instance_methods.include?( :configuration_setting ).should == false
798
- respond_to?( :configuration_setting ).should == false
799
- instance_variables.empty?.should == true
800
- end
801
- setting_class_including_instance = ClassIncluding.new
802
- setting_class_including_instance.respond_to?( :configuration_setting ).should == false
803
- setting_class_including_instance.instance_variables.empty?.should == true
804
- class ClassExtending
805
- extend CascadingConfiguration::Hash::ObjectConfigurationMockModuleIncluded
806
- instance_methods.include?( :configuration_setting ).should == false
807
- respond_to?( :configuration_setting ).should == false
808
- instance_variables.empty?.should == true
809
- end
810
- setting_class_including_instance = ClassExtending.new
811
- setting_class_including_instance.respond_to?( :configuration_setting ).should == false
812
- setting_class_including_instance.instance_variables.empty?.should == true
813
- end
814
-
815
- class CascadingConfiguration::Hash::ObjectConfigurationMockClass
816
- include CascadingConfiguration::Hash::ObjectConfigurationMockModuleIncluded::SubmoduleIncluding
817
- instance_methods.include?( :configuration_setting ).should == false
818
- respond_to?( :configuration_setting ).should == false
819
- instance_variables.empty?.should == true
820
- end
821
-
822
- object_instance_one = CascadingConfiguration::Hash::ObjectConfigurationMockClass.new
823
- object_instance_one.respond_to?( :configuration_setting ).should == false
824
- object_instance_one.instance_variables.empty?.should == true
825
-
826
- class CascadingConfiguration::Hash::ObjectConfigurationMockClassSub1 < CascadingConfiguration::Hash::ObjectConfigurationMockClass
827
- instance_methods.include?( :configuration_setting ).should == false
828
- respond_to?( :configuration_setting ).should == false
829
- instance_variables.empty?.should == true
830
- end
831
-
832
- object_instance_two = CascadingConfiguration::Hash::ObjectConfigurationMockClassSub1.new
833
- object_instance_two.respond_to?( :configuration_setting ).should == false
834
- object_instance_two.instance_variables.empty?.should == true
835
-
836
- end
837
-
838
- end