cascading-configuration-hash 1.1.6 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Cascading Configuration #
1
+ # Cascading Configuration Hash #
2
2
 
3
3
  http://rubygems.org/gems/cascading-configuration-hash
4
4
 
@@ -8,336 +8,254 @@ Adds methods for cascading configuration hashes. Support package for cascading-c
8
8
 
9
9
  # Summary #
10
10
 
11
- ## :attr_configuration_hash ##
12
-
13
- :attr_configuration_hash provides inheritable configuration that cascades downward.
14
-
15
- Configuration inheritance can cascade through modules, classes, and instances.
11
+ Cascading configuration methods for hashes, which returns the appropriate lowest accumulated value. Configuration inheritance can cascade through modules, classes, and to instances.
16
12
 
17
- :attr_configuration_hash defines a single attribute accessor that composes the set of configuration values appropriate to the ancestor level being queried (merging downward from most distant ancestor to self). An internal cache is kept, and any configuration updates that occur to higher-level ancestors cascade immediately downward.
13
+ This means that we can create configuration modules, optionally setting configuration defaults, and include those configuration modules in other modules or classes.
18
14
 
19
15
  # Install #
20
16
 
21
- * sudo gem install cascading-configuration-hash
17
+ * sudo gem install cascading-configuration
22
18
 
23
19
  # Usage #
24
20
 
25
- ## First Module ##
26
-
27
- 1. Define initial configuration in a module.
28
-
29
- A class works just as well, but we can't use a module in the same chain if we start with a class.
30
-
31
- * Include module to enable attr_configuration_hash.
32
-
33
- ```ruby
34
-
35
- module CascadingConfiguration::MockModule
36
- include CascadingConfiguration::Hash
37
- end
38
-
39
- ```
40
-
41
- * Declare attr_configuration_hash.
21
+ Including the module will enable support for singleton and for instances.
42
22
 
43
23
  ```ruby
44
-
45
- module CascadingConfiguration::MockModule
46
- attr_configuration_hash :some_hash_configuration
47
- end
48
-
24
+ module AnyModuleOrClass
25
+ include CascadingConfiguration
26
+ end
49
27
  ```
50
28
 
51
- * Set initial value.
29
+ Extending the module will enable support for singleton only.
52
30
 
53
31
  ```ruby
54
-
55
- module CascadingConfiguration::MockModule
56
- self.some_hash_configuration = { :some_value => :some_value }
57
- end
58
-
32
+ module AnyModuleOrClass
33
+ extend CascadingConfiguration
34
+ end
59
35
  ```
60
36
 
61
- * Verify initial configuration value
62
-
63
- ```ruby
37
+ Including or extending CascadingConfiguration includes or extends:
64
38
 
65
- module CascadingConfiguration::MockModule
66
- # => some_hash_configuration.should == { :some_value => :some_value }
67
- end
39
+ * CascadingConfiguration::Variable
68
40
 
69
- ```
41
+ ## :attr_configuration_hash ##
70
42
 
71
- ## Including Module 1 ##
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).
72
44
 
73
- 2. Include initial module in another module.
45
+ An internal cache is kept, and any configuration updates that occur to higher-level ancestors cascade immediately downward.
74
46
 
75
- Including the module that has included a CascadingConfiguration module is the same as including a CascadingConfiguration module.
47
+ Define initial configuration in a module or class:
76
48
 
77
49
  ```ruby
50
+ module SomeModule
78
51
 
79
- module CascadingConfiguration::MockModule2
80
- include CascadingConfiguration::MockModule
81
- end
52
+ include CascadingConfiguration::Hash
82
53
 
83
- ```
54
+ attr_configuration_hash :some_hash_setting
84
55
 
85
- * Verify inherited value
56
+ some_hash_setting # => nil
86
57
 
87
- ```ruby
58
+ some_hash_setting[ :some_setting ] = :some_value
88
59
 
89
- module CascadingConfiguration::MockModule2
90
- # => some_hash_configuration.should == { :some_value => :some_value }
91
- end
60
+ some_hash_setting[ :some_setting ] # => :some_value
92
61
 
62
+ end
93
63
  ```
94
64
 
95
- * Override inherited value
65
+ Include initial module in a module or class:
96
66
 
97
67
  ```ruby
68
+ class SomeClass
98
69
 
99
- module CascadingConfiguration::MockModule2
100
- self.some_hash_configuration = { :module_value => :some_value }
101
- end
102
-
103
- ```
70
+ include SomeModule
104
71
 
105
- * Verify local override value
72
+ some_hash_setting[ :some_setting ] # => :some_value
106
73
 
107
- ```ruby
74
+ self.some_hash_setting.replace( :some_other_setting => :some_other_value )
108
75
 
109
- module CascadingConfiguration::MockModule2
110
- # => some_hash_configuration.should == { :module_value => :some_value }
111
- end
76
+ some_hash_setting # => { :some_other_setting => :some_other_value }
112
77
 
78
+ end
113
79
  ```
114
80
 
115
- ## Including Module 2 ##
116
-
117
- 3. Include second module in another module.
81
+ And it cascades to instances:
118
82
 
119
83
  ```ruby
84
+ instance = SomeClass.new
120
85
 
121
- module CascadingConfiguration::MockModule3
122
- include CascadingConfiguration::MockModule2
123
- end
124
-
125
- ```
126
-
127
- * Verify inherited value
128
-
129
- ```ruby
86
+ instance.some_hash_setting.should == { :some_other_setting => :some_other_value }
130
87
 
131
- module CascadingConfiguration::MockModule3
132
- # => some_array_configuration.should == { :module_value => :some_value }
133
- end
88
+ instance.some_hash_setting.delete( :some_other_setting )
134
89
 
90
+ instance.some_hash_setting.should == {}
135
91
  ```
136
92
 
137
- ## Top Class ##
138
-
139
- 4. Include third module in a class.
93
+ ### :attr_module_configuration_hash, :attr_class_configuration_hash ###
140
94
 
141
- ```ruby
142
-
143
- class CascadingConfiguration::MockClass
144
- include CascadingConfiguration::MockModule3
145
- end
95
+ :attr_class_configuration_hash works like :attr_configuration_hash but does not cascade to instances.
146
96
 
147
- ```
148
-
149
- * Verify inherited value
97
+ Define initial configuration in a module or class:
150
98
 
151
99
  ```ruby
100
+ module SomeModule
152
101
 
153
- class CascadingConfiguration::MockClass
154
- # => some_hash_configuration.should == { :module_value => :some_value }
155
- end
102
+ include CascadingConfiguration::Hash
156
103
 
157
- ```
104
+ attr_class_configuration_hash :some_hash_setting
158
105
 
159
- * Override inherited value
106
+ some_hash_setting # => nil
160
107
 
161
- ```ruby
108
+ some_hash_setting[ :some_setting ] = :some_value
162
109
 
163
- class CascadingConfiguration::MockClass
164
- self.some_hash_configuration = { :another_value => :some_value }
165
- end
110
+ some_hash_setting[ :some_setting ] # => :some_value
166
111
 
112
+ end
167
113
  ```
168
114
 
169
- * Verify local override value
115
+ Include initial module in a module or class:
170
116
 
171
117
  ```ruby
118
+ class SomeClass
172
119
 
173
- class CascadingConfiguration::MockClass
174
- # => some_hash_configuration.should == { :another_value => :some_value }
175
- end
176
-
177
- ```
178
-
179
- ## Instance of Top Class ##
120
+ include SomeModule
180
121
 
181
- 5. Instantiate class.
122
+ some_hash_setting[ :some_setting ] # => :some_value
182
123
 
183
- ```ruby
124
+ self.some_hash_setting.replace( :some_other_setting => :some_other_value )
184
125
 
185
- object_instance_one = CascadingConfiguration::MockClass.new
126
+ some_hash_setting # => { :some_other_setting => :some_other_value }
186
127
 
128
+ end
187
129
  ```
188
130
 
189
- * Verify inherited value
131
+ And it does not cascade to instances:
190
132
 
191
133
  ```ruby
134
+ instance = SomeClass.new
192
135
 
193
- # => object_instance_one.some_hash_configuration.should == { :another_value => :some_value }
194
-
136
+ instance.respond_to?( :some_hash_setting ).should == false
195
137
  ```
196
138
 
197
- * Override inherited value
198
-
199
- ```ruby
200
-
201
- object_instance_one.some_hash_configuration = { :yet_another_value => :some_value }
139
+ ### :attr_local_configuration_hash ###
202
140
 
203
- ```
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).
204
142
 
205
- * Verify local override value
143
+ Define initial configuration in a module or class:
206
144
 
207
145
  ```ruby
146
+ module SomeModule
208
147
 
209
- # => object_instance_one.some_hash_configuration.should == { :yet_another_value => :some_value }
210
- # => CascadingConfiguration::MockClass.some_hash_configuration.should == { :another_value => :some_value }
211
- # => CascadingConfiguration::MockModule.some_hash_configuration.should == { :some_value => :some_value }
212
-
213
- ```
214
-
215
- # First Inheriting Class #
216
-
217
- 6. Inheriting class.
148
+ include CascadingConfiguration::Hash
218
149
 
219
- Inheriting class should not get any settings from instance of superclass.
150
+ attr_class_configuration_hash :some_hash_setting
220
151
 
221
- * Verify inherited value
152
+ some_hash_setting # => nil
222
153
 
223
- ```ruby
154
+ some_hash_setting[ :some_setting ] = :some_value
224
155
 
225
- class CascadingConfiguration::MockClassSub1 < CascadingConfiguration::MockClass
226
- # => some_hash_configuration.should == { :another_value => :some_value }
227
- end
156
+ some_hash_setting[ :some_setting ] # => :some_value
228
157
 
158
+ end
229
159
  ```
230
160
 
231
- * Override inherited value
161
+ Include initial module in a module or class:
232
162
 
233
163
  ```ruby
164
+ class SomeClass
234
165
 
235
- class CascadingConfiguration::MockClassSub1 < CascadingConfiguration::MockClass
236
- self.some_hash_configuration = { :a_value_not_yet_used => :some_value }
237
- end
166
+ include SomeModule
238
167
 
239
- ```
168
+ respond_to?( :some_hash_setting ).should == false
240
169
 
241
- * Verify local override value
170
+ end
171
+ ```
242
172
 
243
- ```ruby
173
+ ## Additional Functionality ##
244
174
 
245
- class CascadingConfiguration::MockClassSub1 < CascadingConfiguration::MockClass
246
- # => some_hash_configuration.should == { :a_value_not_yet_used => :some_value }
247
- # => CascadingConfiguration::MockClass.some_hash_configuration.should == { :another_value => :some_value }
248
- # => CascadingConfiguration::MockModule.some_hash_configuration.should == { :some_value => :some_value }
249
- end
175
+ Cascading-configuration also provides several other convenience functions.
250
176
 
251
- ```
177
+ ### Variable Name Prefixing ###
252
178
 
253
- ## Instance of First Inheriting Class ##
179
+ Configuration prefix can be set so that variables use property name with the configuration prefix prepended.
254
180
 
255
- 7. Instantiate first inheriting class.
181
+ This can be done in order defined (current configuration prefix is stored for configuration), or it can be specified on a per-property basis.
256
182
 
257
183
  ```ruby
184
+ module SomeModule
258
185
 
259
- object_instance_two = CascadingConfiguration::MockClassSub1.new
186
+ include CascadingConfiguration
260
187
 
261
- ```
188
+ attr_configuration :some_setting
262
189
 
263
- * Verify inherited value
190
+ self.some_setting = :a_value
264
191
 
265
- ```ruby
192
+ instance_variables.include?( :@some_setting ) # => true
266
193
 
267
- # => object_instance_two.some_hash_configuration.should == { :a_value_not_yet_used => :some_value }
268
- # => object_instance_one.some_hash_configuration.should == { :yet_another_value => :some_value }
269
- # => CascadingConfiguration::MockClass.some_hash_configuration.should == { :another_value => :some_value }
270
- # => CascadingConfiguration::MockModule.some_hash_configuration.should == { :some_value => :some_value }
194
+ # we can declare a prefix for specific properties
195
+ attr_configuration_prefix '__configuration_prefix__', :some_other_setting
271
196
 
272
- ```
197
+ attr_configuration :some_other_setting, :yet_another_setting
273
198
 
274
- ## Second Inheriting Class ##
199
+ self.some_setting = :some_value
200
+ self.yet_another_setting = :another_value
275
201
 
276
- 8. Second inheriting class.
202
+ instance_variables.include?( :@some_other_setting ) # => false
203
+ instance_variables.include?( :@__configuration_prefix__some_other_setting ) # => true
204
+ instance_variables.include?( :@yet_another_setting ) # => true
277
205
 
278
- * Verify inherited value
206
+ # or we can declare a prefix for all properties defined after prefix is declared
207
+ attr_configuration_prefix '__another_configuration_prefix__'
279
208
 
280
- ```ruby
209
+ attr_configuration :still_another_prefix
281
210
 
282
- class CascadingConfiguration::MockClassSub2 < CascadingConfiguration::MockClassSub1
283
- # => some_hash_configuration.should == { :a_value_not_yet_used => :some_value }
284
- end
211
+ instance_variables.include?( :@still_another_prefix ) # => false
212
+ instance_variables.include?( :@__another_configuration_prefix__still_another_prefix ) # => true
285
213
 
214
+ end
286
215
  ```
287
216
 
288
- * Override inherited value
217
+ ### Method Redefinition ###
289
218
 
290
- ```ruby
291
-
292
- class CascadingConfiguration::MockClassSub2 < CascadingConfiguration::MockClassSub1
293
- self.some_hash_configuration = { :another_value_not_yet_used => :some_value }
294
- end
219
+ Any declared configuration is defined in order to support locally redefining the method and accessing the original by calling super.
295
220
 
296
- ```
221
+ ```ruby
222
+ module SomeModule
297
223
 
298
- * Verify local override value
224
+ include CascadingConfiguration
299
225
 
300
- ```ruby
226
+ attr_configuration :some_array_setting
301
227
 
302
- class CascadingConfiguration::MockClassSub2 < CascadingConfiguration::MockClassSub1
303
- # => some_hash_configuration.should == { :another_value_not_yet_used => :some_value }
228
+ def some_array_setting=( value )
229
+ puts 'Replacing configuration array!'
230
+ super
304
231
  end
305
232
 
233
+ end
306
234
  ```
307
235
 
308
- ## Instance of Second Inheriting Class ##
236
+ ### Hidden Configuration ###
309
237
 
310
- 9. Instantiate Second Inheriting Class.
238
+ #### :attr_hide ####
311
239
 
312
- ```ruby
313
-
314
- object_instance_three = CascadingConfiguration::MockClassSub2.new
315
-
316
- ```
317
-
318
- * Verify inherited value
240
+ Coming soon.
319
241
 
320
242
  ```ruby
243
+ module SomeModule
321
244
 
322
- # => object_instance_three.some_hash_configuration.should == { :another_value_not_yet_used => :some_value }
245
+ include CascadingConfiguration
323
246
 
324
- ```
247
+ attr_configuration :some_array_setting
325
248
 
326
- * Override inherited value
249
+ instance_variables.include?( :@some_array_setting ) # => true
327
250
 
328
- ```ruby
251
+ attr_hide :some_array_setting
329
252
 
330
- object_instance_three.some_hash_configuration = { :one_more_unused_value => :some_value }
253
+ instance_variables.include?( :@some_array_setting ) # => false
331
254
 
255
+ end
332
256
  ```
333
257
 
334
- * Verify local override value
335
-
336
- ```ruby
337
-
338
- # => object_instance_three.some_hash_configuration.should == { :one_more_unused_value => :some_value }
339
-
340
- ```
258
+ Causes configuration variable to be stored in external context so that it is not included in instance variables.
341
259
 
342
260
  # License #
343
261
 
data/README.rdoc CHANGED
@@ -1,30 +1,34 @@
1
1
  == Cascading Configuration
2
2
 
3
- http://rubygems.org/gems/cascading-configuration
3
+ http://rubygems.org/gems/cascading-configuration-hash
4
4
 
5
5
  == Description
6
6
 
7
- Adds methods for cascading configurations.
7
+ Adds methods for cascading configuration hashes. Support package for cascading-configuration.
8
8
 
9
9
  == Summary
10
10
 
11
- Cascading configuration methods for single settings, arrays, hashes.
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.
12
14
 
13
15
  == :attr_configuration_hash
14
16
 
15
- :attr_configuration_hash provides inheritable configuration that cascades downward.
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.
16
20
 
17
- Configuration inheritance can cascade through modules, classes, and instances.
21
+ :attr_class_configuration_hash works like :attr_configuration_hash but does not cascade to instances.
18
22
 
19
- :attr_configuration_hash defines a single attribute accessor that composes the set of configuration values appropriate to the ancestor level being queried (merging downward from most distant ancestor to self). An internal cache is kept, and any configuration updates that occur to higher-level ancestors cascade immediately downward.
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).
20
24
 
21
25
  == Install
22
26
 
23
- * sudo gem install cascading-configuration
27
+ * sudo gem install cascading-configuration-hash
24
28
 
25
29
  == Usage
26
30
 
27
- See supporting package README markdown files (README.md) for examples.
31
+ See README.md
28
32
 
29
33
  == License
30
34
 
@@ -13,7 +13,7 @@ module CascadingConfiguration
13
13
  class LocalConfigurationHash < Hash
14
14
  end
15
15
  module Hash
16
- module ConfigurationAccessors
16
+ module AccessorDefinitionMethods
17
17
  end
18
18
  module Interface
19
19
  end
@@ -30,6 +30,6 @@ require_relative 'cascading-configuration-hash/CascadingConfiguration/Compositin
30
30
  require_relative 'cascading-configuration-hash/CascadingConfiguration/LocalConfigurationHash.rb'
31
31
  require_relative 'cascading-configuration-hash/CascadingConfiguration/_private_/LocalConfigurationHash.rb'
32
32
  require_relative 'cascading-configuration-hash/CascadingConfiguration/Hash.rb'
33
- require_relative 'cascading-configuration-hash/CascadingConfiguration/Hash/ConfigurationAccessors.rb'
33
+ require_relative 'cascading-configuration-hash/CascadingConfiguration/Hash/AccessorDefinitionMethods.rb'
34
34
  require_relative 'cascading-configuration-hash/CascadingConfiguration/Hash/Interface.rb'
35
35
  require_relative 'cascading-configuration-hash/CascadingConfiguration/Hash/ModuleInclusionExtensionSupport.rb'
@@ -34,7 +34,7 @@ module CascadingConfiguration::Hash
34
34
  class_or_module.instance_eval do
35
35
  extend module_self
36
36
  extend module_self::Interface
37
- extend module_self::ConfigurationAccessors
37
+ extend module_self::AccessorDefinitionMethods
38
38
  extend CascadingConfiguration::Hash::ModuleInclusionExtensionSupport unless is_a?( Class )
39
39
  end
40
40
  end
@@ -47,7 +47,7 @@ module CascadingConfiguration::Hash
47
47
  module_self = self
48
48
  class_or_module.instance_eval do
49
49
  extend module_self::Interface
50
- extend module_self::ConfigurationAccessors
50
+ extend module_self::AccessorDefinitionMethods
51
51
  end
52
52
  end
53
53
 
@@ -1,5 +1,5 @@
1
1
 
2
- module CascadingConfiguration::Hash::ConfigurationAccessors
2
+ module CascadingConfiguration::Hash::AccessorDefinitionMethods
3
3
 
4
4
  extend CascadingConfiguration::InternalModuleStub
5
5
 
@@ -9,8 +9,8 @@ module CascadingConfiguration::Hash::ConfigurationAccessors
9
9
 
10
10
  def define_cascading_hash_setter( configuration_name )
11
11
  configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
12
- [ accessor_instance_support, accessor_module_support ].compact.each do |accessor_support_module|
13
- accessor_support_module.module_eval do
12
+ [ accessor_instance_support, accessor_module_support ].compact.each do |accessor_module_support|
13
+ accessor_module_support.module_eval do
14
14
  define_method( configuration_setter_name ) do |hash|
15
15
  # we want the hash to supplant existing config
16
16
  return composite_hash_for_cascading_configuration( configuration_name ).replace( hash )
@@ -25,8 +25,8 @@ module CascadingConfiguration::Hash::ConfigurationAccessors
25
25
 
26
26
  def define_cascading_hash_getter( configuration_name )
27
27
  configuration_getter_name = configuration_name
28
- [ accessor_instance_support, accessor_module_support ].compact.each do |accessor_support_module|
29
- accessor_support_module.module_eval do
28
+ [ accessor_instance_support, accessor_module_support ].compact.each do |accessor_module_support|
29
+ accessor_module_support.module_eval do
30
30
  define_method( configuration_getter_name ) do
31
31
  return composite_hash_for_cascading_configuration( configuration_name )
32
32
  end
@@ -67,7 +67,7 @@ module CascadingConfiguration::Hash::ConfigurationAccessors
67
67
 
68
68
  def define_local_configuration_hash_setter( configuration_name )
69
69
  configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
70
- accessor_instance_support.module_eval do
70
+ accessor_local_instance_support.module_eval do
71
71
  define_method( configuration_setter_name ) do |hash|
72
72
  # we want the hash to supplant existing config
73
73
  return composite_hash_for_cascading_configuration( configuration_name ).replace( hash )
@@ -81,7 +81,7 @@ module CascadingConfiguration::Hash::ConfigurationAccessors
81
81
 
82
82
  def define_local_configuration_hash_getter( configuration_name )
83
83
  configuration_getter_name = configuration_name
84
- accessor_instance_support.module_eval do
84
+ accessor_local_instance_support.module_eval do
85
85
  define_method( configuration_getter_name ) do
86
86
  return composite_hash_for_cascading_configuration( configuration_name )
87
87
  end
@@ -23,13 +23,13 @@ module CascadingConfiguration::Hash::Interface
23
23
 
24
24
  end
25
25
 
26
- ###################################
27
- # attr_class_configuration_hash #
28
- ###################################
26
+ ####################################
27
+ # attr_module_configuration_hash #
28
+ ####################################
29
29
 
30
30
  # defines configuration in class or module
31
31
  # configuration cascades downward to last class or module
32
- def attr_class_configuration_hash( *property_names, & compositing_block )
32
+ def attr_module_configuration_hash( *property_names, & compositing_block )
33
33
 
34
34
  property_names.each do |this_property_name|
35
35
  accessor_module_support.set_compositing_proc( this_property_name, compositing_block ) if block_given?
@@ -42,6 +42,7 @@ module CascadingConfiguration::Hash::Interface
42
42
  return self
43
43
 
44
44
  end
45
+ alias_method :attr_class_configuration_hash, :attr_module_configuration_hash
45
46
 
46
47
  ###################################
47
48
  # attr_local_configuration_hash #
@@ -50,7 +51,9 @@ module CascadingConfiguration::Hash::Interface
50
51
  # defines configuration in present class or module context
51
52
  # configuration does not cascade
52
53
  def attr_local_configuration_hash( *property_names, & compositing_block )
53
-
54
+
55
+ CascadingConfiguration::Variable.define_accessor_local_instance_support( self )
56
+
54
57
  property_names.each do |this_property_name|
55
58
  accessor_module_support.set_compositing_proc( this_property_name, compositing_block ) if block_given?
56
59
  # define configuration setter
@@ -1,7 +1,7 @@
1
1
 
2
2
  require_relative '../../../lib/cascading-configuration-hash.rb'
3
3
 
4
- describe CascadingConfiguration::Hash::ConfigurationAccessors do
4
+ describe CascadingConfiguration::Hash::AccessorDefinitionMethods do
5
5
 
6
6
  ######################################
7
7
  # define_cascading_hash_setter #
@@ -11,7 +11,7 @@ describe CascadingConfiguration::Hash::ConfigurationAccessors do
11
11
  it 'can define a method to get and modify the configuration hash' do
12
12
  class CascadingConfiguration::Hash::Mock
13
13
  include CascadingConfiguration::Variable
14
- extend CascadingConfiguration::Hash::ConfigurationAccessors
14
+ extend CascadingConfiguration::Hash::AccessorDefinitionMethods
15
15
  include CascadingConfiguration::Hash::ObjectInstance
16
16
  extend CascadingConfiguration::Hash::Interface
17
17
  end
@@ -21,7 +21,7 @@ describe CascadingConfiguration::Hash do
21
21
  # => instances of including classes get configurations
22
22
  # => extending modules and classes get attr_configuration and configurations
23
23
  # => instances of extending classes get nothing
24
- module CascadingConfiguration::Hash::MockModuleExtended
24
+ module CascadingConfiguration::Hash::ConfigurationMockModuleExtended
25
25
  extend CascadingConfiguration::Hash
26
26
  # => singleton gets attr_configuration and configurations
27
27
  respond_to?( :attr_configuration_hash ).should == true
@@ -33,31 +33,31 @@ describe CascadingConfiguration::Hash do
33
33
  instance_methods.include?( :configuration_setting ).should == false
34
34
  # => including modules and classes get nothing
35
35
  module SubmoduleIncluding
36
- include CascadingConfiguration::Hash::MockModuleExtended
36
+ include CascadingConfiguration::Hash::ConfigurationMockModuleExtended
37
37
  instance_methods.include?( :configuration_setting ).should == false
38
38
  respond_to?( :configuration_setting ).should == false
39
39
  end
40
40
  # => extending modules and classes get nothing
41
41
  module SubmoduleExtending
42
- extend CascadingConfiguration::Hash::MockModuleExtended
42
+ extend CascadingConfiguration::Hash::ConfigurationMockModuleExtended
43
43
  instance_methods.include?( :configuration_setting ).should == false
44
44
  respond_to?( :configuration_setting ).should == false
45
45
  end
46
46
  # => instances of including and extending classes get nothing
47
47
  class ClassIncluding
48
- include CascadingConfiguration::Hash::MockModuleExtended
48
+ include CascadingConfiguration::Hash::ConfigurationMockModuleExtended
49
49
  instance_methods.include?( :configuration_setting ).should == false
50
50
  respond_to?( :configuration_setting ).should == false
51
51
  end
52
52
  class ClassExtending
53
- extend CascadingConfiguration::Hash::MockModuleExtended
53
+ extend CascadingConfiguration::Hash::ConfigurationMockModuleExtended
54
54
  instance_methods.include?( :configuration_setting ).should == false
55
55
  respond_to?( :configuration_setting ).should == false
56
56
  end
57
57
  end
58
58
 
59
59
  # * module included with setting
60
- module CascadingConfiguration::Hash::MockModuleIncluded
60
+ module CascadingConfiguration::Hash::ConfigurationMockModuleIncluded
61
61
  include CascadingConfiguration::Hash
62
62
  # => singleton gets attr_configuration and configurations
63
63
  respond_to?( :attr_configuration_hash ).should == true
@@ -69,7 +69,7 @@ describe CascadingConfiguration::Hash do
69
69
  instance_methods.include?( :configuration_setting ).should == true
70
70
  # => including modules and classes get attr_configuration and configurations
71
71
  module SubmoduleIncluding
72
- include CascadingConfiguration::Hash::MockModuleIncluded
72
+ include CascadingConfiguration::Hash::ConfigurationMockModuleIncluded
73
73
  instance_methods.include?( :configuration_setting ).should == true
74
74
  respond_to?( :configuration_setting ).should == true
75
75
  configuration_setting.should == { :a_configuration => :some_value }
@@ -81,7 +81,7 @@ describe CascadingConfiguration::Hash do
81
81
  end
82
82
  # => extending modules and classes get attr_configuration and configurations
83
83
  module SubmoduleExtending
84
- extend CascadingConfiguration::Hash::MockModuleIncluded
84
+ extend CascadingConfiguration::Hash::ConfigurationMockModuleIncluded
85
85
  # if we're extended then we want to use the eigenclass ancestor chain
86
86
  # - the first ancestor will be the extending module
87
87
  # - the rest of the ancestors will be the extending module's include chain
@@ -96,7 +96,7 @@ describe CascadingConfiguration::Hash do
96
96
  end
97
97
  # => instances of including classes get configurations
98
98
  class ClassIncluding
99
- include CascadingConfiguration::Hash::MockModuleIncluded
99
+ include CascadingConfiguration::Hash::ConfigurationMockModuleIncluded
100
100
  instance_methods.include?( :configuration_setting ).should == true
101
101
  respond_to?( :configuration_setting ).should == true
102
102
  configuration_setting.should == { :a_configuration => :some_value }
@@ -111,7 +111,7 @@ describe CascadingConfiguration::Hash do
111
111
  setting_class_including_instance.configuration_setting.should == { :a_configuration => :some_value }
112
112
  setting_class_including_instance.configuration_setting.delete( :a_configuration )
113
113
  class ClassExtending
114
- extend CascadingConfiguration::Hash::MockModuleIncluded
114
+ extend CascadingConfiguration::Hash::ConfigurationMockModuleIncluded
115
115
  respond_to?( :configuration_setting ).should == true
116
116
  configuration_setting.should == { :a_configuration => :some_value }
117
117
  configuration_setting[ :other_setting ] = :some_value
@@ -124,8 +124,8 @@ describe CascadingConfiguration::Hash do
124
124
  setting_class_including_instance.respond_to?( :configuration_setting ).should == false
125
125
  end
126
126
 
127
- class CascadingConfiguration::Hash::MockClass
128
- include CascadingConfiguration::Hash::MockModuleIncluded::SubmoduleIncluding
127
+ class CascadingConfiguration::Hash::ConfigurationMockClass
128
+ include CascadingConfiguration::Hash::ConfigurationMockModuleIncluded::SubmoduleIncluding
129
129
  configuration_setting.should == { :a_configuration => :some_value }
130
130
  configuration_setting[ :other_setting ] = :some_value
131
131
  configuration_setting.should == { :a_configuration => :some_value,
@@ -134,20 +134,20 @@ describe CascadingConfiguration::Hash do
134
134
  configuration_setting.should == { :a_configuration => :some_value }
135
135
  end
136
136
 
137
- object_instance_one = CascadingConfiguration::Hash::MockClass.new
137
+ object_instance_one = CascadingConfiguration::Hash::ConfigurationMockClass.new
138
138
  object_instance_one.configuration_setting.should == { :a_configuration => :some_value }
139
139
  object_instance_one.configuration_setting[ :some_other_configuration ] = :some_value
140
140
  object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
141
141
  :some_other_configuration => :some_value }
142
142
 
143
- class CascadingConfiguration::Hash::MockClassSub1 < CascadingConfiguration::Hash::MockClass
143
+ class CascadingConfiguration::Hash::ConfigurationMockClassSub1 < CascadingConfiguration::Hash::ConfigurationMockClass
144
144
  configuration_setting.should == { :a_configuration => :some_value }
145
145
  self.configuration_setting[ :another_configuration ] = :some_value
146
146
  configuration_setting.should == { :a_configuration => :some_value,
147
147
  :another_configuration => :some_value }
148
148
  end
149
149
 
150
- object_instance_two = CascadingConfiguration::Hash::MockClassSub1.new
150
+ object_instance_two = CascadingConfiguration::Hash::ConfigurationMockClassSub1.new
151
151
  object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
152
152
  :another_configuration => :some_value }
153
153
  object_instance_two.configuration_setting[ :some_other_configuration ] = :some_value
@@ -156,13 +156,13 @@ describe CascadingConfiguration::Hash do
156
156
  :some_other_configuration => :some_value }
157
157
 
158
158
  # change ancestor setting
159
- CascadingConfiguration::Hash::MockClass.configuration_setting[ :a_yet_unused_configuration ] = :some_value
160
- CascadingConfiguration::Hash::MockClass.configuration_setting.should == { :a_configuration => :some_value,
159
+ CascadingConfiguration::Hash::ConfigurationMockClass.configuration_setting[ :a_yet_unused_configuration ] = :some_value
160
+ CascadingConfiguration::Hash::ConfigurationMockClass.configuration_setting.should == { :a_configuration => :some_value,
161
161
  :a_yet_unused_configuration => :some_value }
162
162
  object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
163
163
  :a_yet_unused_configuration => :some_value,
164
164
  :some_other_configuration => :some_value }
165
- CascadingConfiguration::Hash::MockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
165
+ CascadingConfiguration::Hash::ConfigurationMockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
166
166
  :a_yet_unused_configuration => :some_value,
167
167
  :another_configuration => :some_value }
168
168
  object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
@@ -175,18 +175,18 @@ describe CascadingConfiguration::Hash do
175
175
  object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
176
176
  :a_yet_unused_configuration => :some_value,
177
177
  :some_other_configuration => :some_value }
178
- CascadingConfiguration::Hash::MockClassSub1.configuration_setting.freeze!
179
- CascadingConfiguration::Hash::MockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
178
+ CascadingConfiguration::Hash::ConfigurationMockClassSub1.configuration_setting.freeze!
179
+ CascadingConfiguration::Hash::ConfigurationMockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
180
180
  :a_yet_unused_configuration => :some_value,
181
181
  :another_configuration => :some_value }
182
- CascadingConfiguration::Hash::MockClass.configuration_setting[ :non_cascading_configuration ] = :some_value
183
- CascadingConfiguration::Hash::MockClass.configuration_setting.should == { :a_configuration => :some_value,
182
+ CascadingConfiguration::Hash::ConfigurationMockClass.configuration_setting[ :non_cascading_configuration ] = :some_value
183
+ CascadingConfiguration::Hash::ConfigurationMockClass.configuration_setting.should == { :a_configuration => :some_value,
184
184
  :a_yet_unused_configuration => :some_value,
185
185
  :non_cascading_configuration => :some_value }
186
186
  object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
187
187
  :a_yet_unused_configuration => :some_value,
188
188
  :some_other_configuration => :some_value }
189
- CascadingConfiguration::Hash::MockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
189
+ CascadingConfiguration::Hash::ConfigurationMockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
190
190
  :a_yet_unused_configuration => :some_value,
191
191
  :another_configuration => :some_value }
192
192
  object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
@@ -194,7 +194,7 @@ describe CascadingConfiguration::Hash do
194
194
  :another_configuration => :some_value,
195
195
  :some_other_configuration => :some_value }
196
196
 
197
- module CascadingConfiguration::Hash::MockModule
197
+ module CascadingConfiguration::Hash::ConfigurationMockModule
198
198
  include CascadingConfiguration::Hash
199
199
  attr_configuration_hash :some_hash do |parent_hash, composite_hash|
200
200
  parent_hash.each do |this_key, this_data|
@@ -210,8 +210,8 @@ describe CascadingConfiguration::Hash do
210
210
  self.some_hash.should == { :one => 1, :two => 2 }
211
211
  end
212
212
 
213
- module CascadingConfiguration::Hash::MockModule2
214
- include CascadingConfiguration::Hash::MockModule
213
+ module CascadingConfiguration::Hash::ConfigurationMockModule2
214
+ include CascadingConfiguration::Hash::ConfigurationMockModule
215
215
  self.some_hash.should == { :one => 1, :two => 2 }
216
216
  self.some_hash.replace( { :one => 1, :two => 2 } )
217
217
  self.some_hash.should == { :one => 0, :two => 0 }
@@ -219,4 +219,314 @@ describe CascadingConfiguration::Hash do
219
219
 
220
220
  end
221
221
 
222
+ ####################################
223
+ # attr_module_configuration_hash #
224
+ # attr_class_configuration_hash #
225
+ ####################################
226
+
227
+ it 'can define a class configuration hash, which will not cascade to instances' do
228
+
229
+ # possibilities:
230
+ # * module extended with setting
231
+ # => singleton gets attr_configuration and configurations
232
+ # => including modules and classes get nothing
233
+ # => extending modules and classes get nothing
234
+ # => instances of including and extending classes get nothing
235
+ # * module included with setting
236
+ # => singleton gets attr_configuration and configurations
237
+ # => including modules and classes get attr_configuration and configurations
238
+ # => instances of including classes get configurations
239
+ # => extending modules and classes get attr_configuration and configurations
240
+ # => instances of extending classes get nothing
241
+ module CascadingConfiguration::Hash::ClassConfigurationMockModuleExtended
242
+ extend CascadingConfiguration::Hash
243
+ # => singleton gets attr_configuration and configurations
244
+ respond_to?( :attr_module_configuration_hash ).should == true
245
+ method( :attr_module_configuration_hash ).should == method( :attr_class_configuration_hash )
246
+ attr_module_configuration_hash :configuration_setting
247
+ respond_to?( :configuration_setting ).should == true
248
+ configuration_setting.should == {}
249
+ self.configuration_setting[ :a_configuration ] = :some_value
250
+ configuration_setting.should == { :a_configuration => :some_value }
251
+ instance_methods.include?( :configuration_setting ).should == false
252
+ # => including modules and classes get nothing
253
+ module SubmoduleIncluding
254
+ include CascadingConfiguration::Hash::ClassConfigurationMockModuleExtended
255
+ instance_methods.include?( :configuration_setting ).should == false
256
+ respond_to?( :configuration_setting ).should == false
257
+ end
258
+ # => extending modules and classes get nothing
259
+ module SubmoduleExtending
260
+ extend CascadingConfiguration::Hash::ClassConfigurationMockModuleExtended
261
+ instance_methods.include?( :configuration_setting ).should == false
262
+ respond_to?( :configuration_setting ).should == false
263
+ end
264
+ # => instances of including and extending classes get nothing
265
+ class ClassIncluding
266
+ include CascadingConfiguration::Hash::ClassConfigurationMockModuleExtended
267
+ instance_methods.include?( :configuration_setting ).should == false
268
+ respond_to?( :configuration_setting ).should == false
269
+ end
270
+ class ClassExtending
271
+ extend CascadingConfiguration::Hash::ClassConfigurationMockModuleExtended
272
+ instance_methods.include?( :configuration_setting ).should == false
273
+ respond_to?( :configuration_setting ).should == false
274
+ end
275
+ end
276
+
277
+ # * module included with setting
278
+ module CascadingConfiguration::Hash::ClassConfigurationMockModuleIncluded
279
+ include CascadingConfiguration::Hash
280
+ # => singleton gets attr_configuration and configurations
281
+ respond_to?( :attr_module_configuration_hash ).should == true
282
+ attr_module_configuration_hash :configuration_setting
283
+ respond_to?( :configuration_setting ).should == true
284
+ configuration_setting.should == {}
285
+ self.configuration_setting[ :a_configuration ] = :some_value
286
+ configuration_setting.should == { :a_configuration => :some_value }
287
+ instance_methods.include?( :configuration_setting ).should == false
288
+ # => including modules and classes get attr_configuration and configurations
289
+ module SubmoduleIncluding
290
+ include CascadingConfiguration::Hash::ClassConfigurationMockModuleIncluded
291
+ instance_methods.include?( :configuration_setting ).should == false
292
+ respond_to?( :configuration_setting ).should == true
293
+ configuration_setting.should == { :a_configuration => :some_value }
294
+ configuration_setting[ :other_setting ] = :some_value
295
+ configuration_setting.should == { :a_configuration => :some_value,
296
+ :other_setting => :some_value }
297
+ configuration_setting.delete( :other_setting ).should == :some_value
298
+ configuration_setting.should == { :a_configuration => :some_value }
299
+ end
300
+ # => extending modules and classes get attr_configuration and configurations
301
+ module SubmoduleExtending
302
+ extend CascadingConfiguration::Hash::ClassConfigurationMockModuleIncluded
303
+ # if we're extended then we want to use the eigenclass ancestor chain
304
+ # - the first ancestor will be the extending module
305
+ # - the rest of the ancestors will be the extending module's include chain
306
+ respond_to?( :configuration_setting ).should == true
307
+ configuration_setting.should == { :a_configuration => :some_value }
308
+ configuration_setting[ :other_setting ] = :some_value
309
+ configuration_setting.should == { :a_configuration => :some_value,
310
+ :other_setting => :some_value }
311
+ configuration_setting.delete( :other_setting ).should == :some_value
312
+ configuration_setting.should == { :a_configuration => :some_value }
313
+ instance_methods.include?( :configuration_setting ).should == false
314
+ end
315
+ # => instances of including classes get configurations
316
+ class ClassIncluding
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
+ end
327
+ setting_class_including_instance = ClassIncluding.new
328
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == false
329
+ class ClassExtending
330
+ extend CascadingConfiguration::Hash::ClassConfigurationMockModuleIncluded
331
+ respond_to?( :configuration_setting ).should == true
332
+ instance_methods.include?( :configuration_setting ).should == false
333
+ configuration_setting.should == { :a_configuration => :some_value }
334
+ configuration_setting[ :other_setting ] = :some_value
335
+ configuration_setting.should == { :a_configuration => :some_value,
336
+ :other_setting => :some_value }
337
+ configuration_setting.delete( :other_setting ).should == :some_value
338
+ configuration_setting.should == { :a_configuration => :some_value }
339
+ end
340
+ setting_class_including_instance = ClassExtending.new
341
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == false
342
+ end
343
+
344
+ class CascadingConfiguration::Hash::ClassConfigurationMockClass
345
+ include CascadingConfiguration::Hash::ClassConfigurationMockModuleIncluded::SubmoduleIncluding
346
+ respond_to?( :configuration_setting ).should == true
347
+ instance_methods.include?( :configuration_setting ).should == false
348
+ configuration_setting.should == { :a_configuration => :some_value }
349
+ configuration_setting[ :other_setting ] = :some_value
350
+ configuration_setting.should == { :a_configuration => :some_value,
351
+ :other_setting => :some_value }
352
+ configuration_setting.delete( :other_setting ).should == :some_value
353
+ configuration_setting.should == { :a_configuration => :some_value }
354
+ end
355
+
356
+ object_instance_one = CascadingConfiguration::Hash::ClassConfigurationMockClass.new
357
+ object_instance_one.respond_to?( :a_configuration ).should == false
358
+
359
+ class CascadingConfiguration::Hash::ClassConfigurationMockClassSub1 < CascadingConfiguration::Hash::ClassConfigurationMockClass
360
+ respond_to?( :configuration_setting ).should == true
361
+ instance_methods.include?( :configuration_setting ).should == false
362
+ configuration_setting.should == { :a_configuration => :some_value }
363
+ self.configuration_setting[ :another_configuration ] = :some_value
364
+ configuration_setting.should == { :a_configuration => :some_value,
365
+ :another_configuration => :some_value }
366
+ end
367
+
368
+ object_instance_two = CascadingConfiguration::Hash::ClassConfigurationMockClassSub1.new
369
+ object_instance_two.respond_to?( :a_configuration ).should == false
370
+
371
+ # change ancestor setting
372
+ CascadingConfiguration::Hash::ClassConfigurationMockClass.configuration_setting[ :a_yet_unused_configuration ] = :some_value
373
+ CascadingConfiguration::Hash::ClassConfigurationMockClass.configuration_setting.should == { :a_configuration => :some_value,
374
+ :a_yet_unused_configuration => :some_value }
375
+ CascadingConfiguration::Hash::ClassConfigurationMockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
376
+ :a_yet_unused_configuration => :some_value,
377
+ :another_configuration => :some_value }
378
+
379
+ # freeze ancestor setting
380
+ CascadingConfiguration::Hash::ClassConfigurationMockClassSub1.configuration_setting.freeze!
381
+ CascadingConfiguration::Hash::ClassConfigurationMockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
382
+ :a_yet_unused_configuration => :some_value,
383
+ :another_configuration => :some_value }
384
+ CascadingConfiguration::Hash::ClassConfigurationMockClass.configuration_setting[ :non_cascading_configuration ] = :some_value
385
+ CascadingConfiguration::Hash::ClassConfigurationMockClass.configuration_setting.should == { :a_configuration => :some_value,
386
+ :a_yet_unused_configuration => :some_value,
387
+ :non_cascading_configuration => :some_value }
388
+ CascadingConfiguration::Hash::ClassConfigurationMockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
389
+ :a_yet_unused_configuration => :some_value,
390
+ :another_configuration => :some_value }
391
+
392
+ module CascadingConfiguration::Hash::ClassConfigurationMockModule
393
+ include CascadingConfiguration::Hash
394
+ attr_module_configuration_hash :some_hash do |parent_hash, composite_hash|
395
+ parent_hash.each do |this_key, this_data|
396
+ if existing_value = composite_hash[ this_key ]
397
+ composite_hash[ this_key ] = this_data - existing_value
398
+ else
399
+ composite_hash[ this_key ] = this_data
400
+ end
401
+ end
402
+ composite_hash
403
+ end
404
+ self.some_hash = { :one => 1, :two => 2 }
405
+ self.some_hash.should == { :one => 1, :two => 2 }
406
+ end
407
+
408
+ module CascadingConfiguration::Hash::ClassConfigurationMockModule2
409
+ include CascadingConfiguration::Hash::ClassConfigurationMockModule
410
+ self.some_hash.should == { :one => 1, :two => 2 }
411
+ self.some_hash.replace( { :one => 1, :two => 2 } )
412
+ self.some_hash.should == { :one => 0, :two => 0 }
413
+ end
414
+
415
+ end
416
+
417
+ ###################################
418
+ # attr_local_configuration_hash #
419
+ ###################################
420
+
421
+ it 'can define a local configuration hash, which will not cascade' do
422
+
423
+ # possibilities:
424
+ # * module extended with setting
425
+ # => singleton gets attr_configuration and configurations
426
+ # => including modules and classes get nothing
427
+ # => extending modules and classes get nothing
428
+ # => instances of including and extending classes get nothing
429
+ # * module included with setting
430
+ # => singleton gets attr_configuration and configurations
431
+ # => including modules and classes get attr_configuration and configurations
432
+ # => instances of including classes get configurations
433
+ # => extending modules and classes get attr_configuration and configurations
434
+ # => instances of extending classes get nothing
435
+ module CascadingConfiguration::Hash::LocalConfigurationMockModuleExtended
436
+ extend CascadingConfiguration::Hash
437
+ # => singleton gets attr_configuration and configurations
438
+ respond_to?( :attr_local_configuration_hash ).should == true
439
+ attr_local_configuration_hash :configuration_setting
440
+ respond_to?( :configuration_setting ).should == true
441
+ configuration_setting.should == {}
442
+ self.configuration_setting[ :a_configuration ] = :some_value
443
+ configuration_setting.should == { :a_configuration => :some_value }
444
+ instance_methods.include?( :configuration_setting ).should == false
445
+ # => including modules and classes get nothing
446
+ module SubmoduleIncluding
447
+ include CascadingConfiguration::Hash::LocalConfigurationMockModuleExtended
448
+ instance_methods.include?( :configuration_setting ).should == false
449
+ respond_to?( :configuration_setting ).should == false
450
+ end
451
+ # => extending modules and classes get nothing
452
+ module SubmoduleExtending
453
+ extend CascadingConfiguration::Hash::LocalConfigurationMockModuleExtended
454
+ instance_methods.include?( :configuration_setting ).should == false
455
+ respond_to?( :configuration_setting ).should == false
456
+ end
457
+ # => instances of including and extending classes get nothing
458
+ class ClassIncluding
459
+ include CascadingConfiguration::Hash::LocalConfigurationMockModuleExtended
460
+ instance_methods.include?( :configuration_setting ).should == false
461
+ respond_to?( :configuration_setting ).should == false
462
+ end
463
+ class ClassExtending
464
+ extend CascadingConfiguration::Hash::LocalConfigurationMockModuleExtended
465
+ instance_methods.include?( :configuration_setting ).should == false
466
+ respond_to?( :configuration_setting ).should == false
467
+ end
468
+ end
469
+
470
+ # * module included with setting
471
+ module CascadingConfiguration::Hash::LocalConfigurationMockModuleIncluded
472
+ include CascadingConfiguration::Hash
473
+ # => singleton gets attr_configuration and configurations
474
+ respond_to?( :attr_local_configuration_hash ).should == true
475
+ attr_local_configuration_hash :configuration_setting
476
+ respond_to?( :configuration_setting ).should == true
477
+ configuration_setting.should == {}
478
+ self.configuration_setting[ :a_configuration ] = :some_value
479
+ configuration_setting.should == { :a_configuration => :some_value }
480
+ instance_methods.include?( :configuration_setting ).should == false
481
+ # => including modules and classes get attr_configuration and configurations
482
+ module SubmoduleIncluding
483
+ include CascadingConfiguration::Hash::LocalConfigurationMockModuleIncluded
484
+ instance_methods.include?( :configuration_setting ).should == false
485
+ respond_to?( :configuration_setting ).should == false
486
+ end
487
+ # => extending modules and classes get attr_configuration and configurations
488
+ module SubmoduleExtending
489
+ extend CascadingConfiguration::Hash::LocalConfigurationMockModuleIncluded
490
+ # if we're extended then we want to use the eigenclass ancestor chain
491
+ # - the first ancestor will be the extending module
492
+ # - the rest of the ancestors will be the extending module's include chain
493
+ instance_methods.include?( :configuration_setting ).should == false
494
+ respond_to?( :configuration_setting ).should == false
495
+ end
496
+ # => instances of including classes get configurations
497
+ class ClassIncluding
498
+ include CascadingConfiguration::Hash::LocalConfigurationMockModuleIncluded
499
+ instance_methods.include?( :configuration_setting ).should == false
500
+ respond_to?( :configuration_setting ).should == false
501
+ end
502
+ setting_class_including_instance = ClassIncluding.new
503
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == false
504
+ class ClassExtending
505
+ extend CascadingConfiguration::Hash::LocalConfigurationMockModuleIncluded
506
+ instance_methods.include?( :configuration_setting ).should == false
507
+ respond_to?( :configuration_setting ).should == false
508
+ end
509
+ setting_class_including_instance = ClassExtending.new
510
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == false
511
+ end
512
+
513
+ class CascadingConfiguration::Hash::LocalConfigurationMockClass
514
+ include CascadingConfiguration::Hash::LocalConfigurationMockModuleIncluded::SubmoduleIncluding
515
+ instance_methods.include?( :configuration_setting ).should == false
516
+ respond_to?( :configuration_setting ).should == false
517
+ end
518
+
519
+ object_instance_one = CascadingConfiguration::Hash::LocalConfigurationMockClass.new
520
+ object_instance_one.respond_to?( :a_configuration ).should == false
521
+
522
+ class CascadingConfiguration::Hash::LocalConfigurationMockClassSub1 < CascadingConfiguration::Hash::LocalConfigurationMockClass
523
+ instance_methods.include?( :configuration_setting ).should == false
524
+ respond_to?( :configuration_setting ).should == false
525
+ end
526
+
527
+ object_instance_two = CascadingConfiguration::Hash::LocalConfigurationMockClassSub1.new
528
+ object_instance_two.respond_to?( :a_configuration ).should == false
529
+
530
+ end
531
+
222
532
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 1
8
- - 6
9
- version: 1.1.6
7
+ - 2
8
+ - 0
9
+ version: 1.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Asher
@@ -43,14 +43,14 @@ files:
43
43
  - lib/cascading-configuration-hash/CascadingConfiguration/_private_/LocalConfigurationHash.rb
44
44
  - lib/cascading-configuration-hash/CascadingConfiguration/CompositingHash/Instance.rb
45
45
  - lib/cascading-configuration-hash/CascadingConfiguration/CompositingHash.rb
46
- - lib/cascading-configuration-hash/CascadingConfiguration/Hash/ConfigurationAccessors.rb
46
+ - lib/cascading-configuration-hash/CascadingConfiguration/Hash/AccessorDefinitionMethods.rb
47
47
  - lib/cascading-configuration-hash/CascadingConfiguration/Hash/Interface.rb
48
48
  - lib/cascading-configuration-hash/CascadingConfiguration/Hash/ModuleInclusionExtensionSupport.rb
49
49
  - lib/cascading-configuration-hash/CascadingConfiguration/Hash.rb
50
50
  - lib/cascading-configuration-hash/CascadingConfiguration/LocalConfigurationHash.rb
51
51
  - lib/cascading-configuration-hash.rb
52
52
  - spec/CascadingConfiguration/CascadingCompositeHash_spec.rb
53
- - spec/CascadingConfiguration/Hash/ConfigurationAccessors_spec.rb
53
+ - spec/CascadingConfiguration/Hash/AccessorDefinitionMethods_spec.rb
54
54
  - spec/CascadingConfiguration/Hash_spec.rb
55
55
  - spec/CascadingConfiguration/LocalConfigurationHash_spec.rb
56
56
  - README.md