cascading-configuration-setting 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -236,28 +236,6 @@ module SomeModule
236
236
  end
237
237
  ```
238
238
 
239
- ### Hidden Configuration ###
240
-
241
- #### :attr_hide ####
242
-
243
- Coming soon.
244
-
245
- ```ruby
246
- module SomeModule
247
-
248
- include CascadingConfiguration
249
-
250
- attr_configuration :some_array_setting
251
-
252
- instance_variables.include?( :@some_array_setting ) # => true
253
-
254
- attr_hide :some_array_setting
255
-
256
- instance_variables.include?( :@some_array_setting ) # => false
257
-
258
- end
259
- ```
260
-
261
239
  Causes configuration variable to be stored in external context so that it is not included in instance variables.
262
240
 
263
241
  # License #
@@ -29,12 +29,11 @@ module CascadingConfiguration::Setting
29
29
  ###################
30
30
 
31
31
  def self.included( class_or_module )
32
- module_self = self
33
32
  class_or_module.instance_eval do
34
- extend module_self
35
- extend module_self::Interface
36
- extend module_self::AccessorDefinitionMethods
37
- extend module_self::ModuleInclusionExtensionSupport unless is_a?( Class )
33
+ extend CascadingConfiguration::Setting
34
+ extend CascadingConfiguration::Setting::Interface
35
+ extend CascadingConfiguration::Setting::AccessorDefinitionMethods
36
+ extend CascadingConfiguration::Setting::ModuleInclusionExtensionSupport unless is_a?( Class )
38
37
  end
39
38
  end
40
39
 
@@ -43,10 +42,9 @@ module CascadingConfiguration::Setting
43
42
  ###################
44
43
 
45
44
  def self.extended( class_or_module )
46
- module_self = self
47
45
  class_or_module.instance_eval do
48
- extend module_self::Interface
49
- extend module_self::AccessorDefinitionMethods
46
+ extend CascadingConfiguration::Setting::Interface
47
+ extend CascadingConfiguration::Setting::AccessorDefinitionMethods
50
48
  end
51
49
  end
52
50
 
@@ -58,15 +56,15 @@ module CascadingConfiguration::Setting
58
56
 
59
57
  configuration = nil
60
58
 
61
- configuration_variable = accessor_module_support.cascading_variable_name( configuration_name )
62
-
63
- ancestor_configuration_chain.each do |this_ancestor|
64
- if this_ancestor.instance_variable_defined?( configuration_variable )
65
- # if our instance defines this configuration, use its setting
66
- configuration = this_ancestor.instance_variable_get( configuration_variable )
67
- break
68
- end
69
- end
59
+ instance_self = self
60
+ accessor_module_support.module_eval do
61
+ instance_self.ancestor_configuration_chain.each do |this_ancestor|
62
+ if has_configuration_variable?( this_ancestor, configuration_name )
63
+ configuration = get_configuration_variable( this_ancestor, configuration_name )
64
+ break
65
+ end
66
+ end
67
+ end
70
68
 
71
69
  return configuration
72
70
 
@@ -9,11 +9,11 @@ module CascadingConfiguration::Setting::AccessorDefinitionMethods
9
9
 
10
10
  def define_cascading_setter( configuration_name )
11
11
  configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
12
- [ accessor_instance_support, accessor_module_support ].compact.each do |accessor_module_support|
13
- accessor_module_support.module_eval do
12
+ [ accessor_instance_support, accessor_module_support ].compact.each do |module_support|
13
+ module_support.module_eval do
14
14
  define_method( configuration_setter_name ) do |value|
15
15
  # configuration setter returns setting variable (variable from self), which is now the ID of value
16
- return instance_variable_set( accessor_module_support.cascading_variable_name( configuration_name ), value )
16
+ return accessor_module_support.set_configuration_variable( self, configuration_name, value )
17
17
  end
18
18
  end
19
19
  end
@@ -26,8 +26,8 @@ module CascadingConfiguration::Setting::AccessorDefinitionMethods
26
26
  def define_cascading_getter( configuration_name )
27
27
  configuration_getter_name = configuration_name
28
28
  module_self = self
29
- [ accessor_instance_support, accessor_module_support ].compact.each do |accessor_module_support|
30
- accessor_module_support.module_eval do
29
+ [ accessor_instance_support, accessor_module_support ].compact.each do |module_support|
30
+ module_support.module_eval do
31
31
  define_method( configuration_getter_name ) do
32
32
  # configuration getter returns current setting value (taken from first superclass with setting)
33
33
  # that means first variable that has been set
@@ -46,7 +46,7 @@ module CascadingConfiguration::Setting::AccessorDefinitionMethods
46
46
  accessor_module_support.module_eval do
47
47
  define_method( configuration_setter_name ) do |value|
48
48
  # configuration setter returns setting variable (variable from self), which is now the ID of value
49
- return instance_variable_set( accessor_module_support.cascading_variable_name( configuration_name ), value )
49
+ return accessor_module_support.set_configuration_variable( self, configuration_name, value )
50
50
  end
51
51
  end
52
52
  end
@@ -75,7 +75,7 @@ module CascadingConfiguration::Setting::AccessorDefinitionMethods
75
75
  accessor_local_instance_support.module_eval do
76
76
  define_method( configuration_setter_name ) do |value|
77
77
  # configuration setter returns setting variable (variable from self), which is now the ID of value
78
- return instance_variable_set( accessor_module_support.cascading_variable_name( configuration_name ), value )
78
+ return accessor_module_support.set_configuration_variable( self, configuration_name, value )
79
79
  end
80
80
  end
81
81
  end
@@ -90,7 +90,7 @@ module CascadingConfiguration::Setting::AccessorDefinitionMethods
90
90
  define_method( configuration_getter_name ) do
91
91
  # configuration getter returns current setting value (taken from first superclass with setting)
92
92
  # that means first variable that has been set
93
- return instance_variable_get( accessor_module_support.cascading_variable_name( configuration_name ) )
93
+ return accessor_module_support.get_configuration_variable( self, configuration_name )
94
94
  end
95
95
  end
96
96
  end
@@ -2,7 +2,7 @@
2
2
  require_relative '../../lib/cascading-configuration-setting.rb'
3
3
 
4
4
  describe CascadingConfiguration::Setting do
5
-
5
+
6
6
  ########################
7
7
  # attr_configuration #
8
8
  ########################
@@ -26,28 +26,33 @@ describe CascadingConfiguration::Setting do
26
26
  self.some_configuration = :our_setting_value
27
27
  some_configuration.should == :our_setting_value
28
28
  instance_methods.include?( :some_configuration ).should == false
29
+ instance_variables.empty?.should == true
29
30
  # => including modules and classes get nothing
30
31
  module SubmoduleIncluding
31
32
  include CascadingConfiguration::Setting::ConfigurationMockExtended
32
33
  instance_methods.include?( :some_configuration ).should == false
33
34
  respond_to?( :some_configuration ).should == false
35
+ instance_variables.empty?.should == true
34
36
  end
35
37
  # => extending modules and classes get nothing
36
38
  module SubmoduleExtending
37
39
  extend CascadingConfiguration::Setting::ConfigurationMockExtended
38
40
  instance_methods.include?( :some_configuration ).should == false
39
41
  respond_to?( :some_configuration ).should == false
42
+ instance_variables.empty?.should == true
40
43
  end
41
44
  # => instances of including and extending classes get nothing
42
45
  class ClassIncluding
43
46
  include CascadingConfiguration::Setting::ConfigurationMockExtended
44
47
  instance_methods.include?( :some_configuration ).should == false
45
48
  respond_to?( :some_configuration ).should == false
49
+ instance_variables.empty?.should == true
46
50
  end
47
51
  class ClassExtending
48
52
  extend CascadingConfiguration::Setting::ConfigurationMockExtended
49
53
  instance_methods.include?( :some_configuration ).should == false
50
54
  respond_to?( :some_configuration ).should == false
55
+ instance_variables.empty?.should == true
51
56
  end
52
57
  end
53
58
 
@@ -61,6 +66,7 @@ describe CascadingConfiguration::Setting do
61
66
  self.some_configuration = :our_setting_value
62
67
  some_configuration.should == :our_setting_value
63
68
  instance_methods.include?( :some_configuration ).should == true
69
+ instance_variables.empty?.should == true
64
70
  # => including modules and classes get attr_configuration and configurations
65
71
  module SubmoduleIncluding
66
72
  include CascadingConfiguration::Setting::ConfigurationMockIncluded
@@ -69,6 +75,7 @@ describe CascadingConfiguration::Setting do
69
75
  some_configuration.should == :our_setting_value
70
76
  self.some_configuration = :another_configuration
71
77
  some_configuration.should == :another_configuration
78
+ instance_variables.empty?.should == true
72
79
  end
73
80
  # => extending modules and classes get attr_configuration and configurations
74
81
  module SubmoduleExtending
@@ -81,6 +88,7 @@ describe CascadingConfiguration::Setting do
81
88
  self.some_configuration = :some_other_configuration
82
89
  some_configuration.should == :some_other_configuration
83
90
  instance_methods.include?( :some_configuration ).should == false
91
+ instance_variables.empty?.should == true
84
92
  end
85
93
  # => instances of including classes get configurations
86
94
  class ClassIncluding
@@ -90,12 +98,14 @@ describe CascadingConfiguration::Setting do
90
98
  some_configuration.should == :our_setting_value
91
99
  self.some_configuration = :another_configuration
92
100
  some_configuration.should == :another_configuration
101
+ instance_variables.empty?.should == true
93
102
  end
94
103
  setting_class_including_instance = ClassIncluding.new
95
104
  setting_class_including_instance.respond_to?( :some_configuration ).should == true
96
105
  setting_class_including_instance.some_configuration.should == :another_configuration
97
106
  self.some_configuration = :our_setting_value
98
107
  some_configuration.should == :our_setting_value
108
+ setting_class_including_instance.instance_variables.empty?.should == true
99
109
  # => instances of extending classes get nothing
100
110
  class ClassExtending
101
111
  extend CascadingConfiguration::Setting::ConfigurationMockIncluded
@@ -104,9 +114,11 @@ describe CascadingConfiguration::Setting do
104
114
  self.some_configuration = :some_other_configuration
105
115
  some_configuration.should == :some_other_configuration
106
116
  instance_methods.include?( :some_configuration ).should == false
117
+ instance_variables.empty?.should == true
107
118
  end
108
119
  setting_class_including_instance = ClassExtending.new
109
120
  setting_class_including_instance.respond_to?( :some_configuration ).should == false
121
+ setting_class_including_instance.instance_variables.empty?.should == true
110
122
  end
111
123
 
112
124
  class CascadingConfiguration::Setting::ConfigurationMockClass
@@ -114,16 +126,19 @@ describe CascadingConfiguration::Setting do
114
126
  some_configuration.should == :another_configuration
115
127
  self.some_configuration = :our_setting_value
116
128
  some_configuration.should == :our_setting_value
129
+ instance_variables.empty?.should == true
117
130
  end
118
131
  class CascadingConfiguration::Setting::ConfigurationMockClassSub1 < CascadingConfiguration::Setting::ConfigurationMockClass
119
132
  some_configuration.should == :our_setting_value
120
133
  self.some_configuration = :our_other_setting_value
121
134
  some_configuration.should == :our_other_setting_value
135
+ instance_variables.empty?.should == true
122
136
  end
123
137
  class CascadingConfiguration::Setting::ConfigurationMockClassSub2 < CascadingConfiguration::Setting::ConfigurationMockClassSub1
124
138
  some_configuration.should == :our_other_setting_value
125
139
  self.some_configuration = :a_third_setting_value
126
140
  some_configuration.should == :a_third_setting_value
141
+ instance_variables.empty?.should == true
127
142
  end
128
143
  end
129
144
 
@@ -152,28 +167,33 @@ describe CascadingConfiguration::Setting do
152
167
  self.some_configuration = :our_setting_value
153
168
  some_configuration.should == :our_setting_value
154
169
  instance_methods.include?( :some_configuration ).should == false
170
+ instance_variables.empty?.should == true
155
171
  # => including modules and classes get nothing
156
172
  module SubmoduleIncluding
157
173
  include CascadingConfiguration::Setting::ClassConfigurationMockExtended
158
174
  instance_methods.include?( :some_configuration ).should == false
159
175
  respond_to?( :some_configuration ).should == false
176
+ instance_variables.empty?.should == true
160
177
  end
161
178
  # => extending modules and classes get nothing
162
179
  module SubmoduleExtending
163
180
  extend CascadingConfiguration::Setting::ClassConfigurationMockExtended
164
181
  instance_methods.include?( :some_configuration ).should == false
165
182
  respond_to?( :some_configuration ).should == false
183
+ instance_variables.empty?.should == true
166
184
  end
167
185
  # => instances of including and extending classes get nothing
168
186
  class ClassIncluding
169
187
  include CascadingConfiguration::Setting::ClassConfigurationMockExtended
170
188
  instance_methods.include?( :some_configuration ).should == false
171
189
  respond_to?( :some_configuration ).should == false
190
+ instance_variables.empty?.should == true
172
191
  end
173
192
  class ClassExtending
174
193
  extend CascadingConfiguration::Setting::ClassConfigurationMockExtended
175
194
  instance_methods.include?( :some_configuration ).should == false
176
195
  respond_to?( :some_configuration ).should == false
196
+ instance_variables.empty?.should == true
177
197
  end
178
198
  end
179
199
 
@@ -187,6 +207,7 @@ describe CascadingConfiguration::Setting do
187
207
  self.some_configuration = :our_setting_value
188
208
  some_configuration.should == :our_setting_value
189
209
  instance_methods.include?( :some_configuration ).should == false
210
+ instance_variables.empty?.should == true
190
211
  # => including modules and classes get attr_module_configuration and configurations
191
212
  module SubmoduleIncluding
192
213
  include CascadingConfiguration::Setting::ClassConfigurationMockIncluded
@@ -195,6 +216,7 @@ describe CascadingConfiguration::Setting do
195
216
  some_configuration.should == :our_setting_value
196
217
  self.some_configuration = :another_configuration
197
218
  some_configuration.should == :another_configuration
219
+ instance_variables.empty?.should == true
198
220
  end
199
221
  # => extending modules and classes get attr_module_configuration and configurations
200
222
  module SubmoduleExtending
@@ -207,6 +229,7 @@ describe CascadingConfiguration::Setting do
207
229
  self.some_configuration = :some_other_configuration
208
230
  some_configuration.should == :some_other_configuration
209
231
  instance_methods.include?( :some_configuration ).should == false
232
+ instance_variables.empty?.should == true
210
233
  end
211
234
  # => instances of including classes get configurations
212
235
  class ClassIncluding
@@ -216,9 +239,11 @@ describe CascadingConfiguration::Setting do
216
239
  some_configuration.should == :our_setting_value
217
240
  self.some_configuration = :another_configuration
218
241
  some_configuration.should == :another_configuration
242
+ instance_variables.empty?.should == true
219
243
  end
220
244
  setting_class_including_instance = ClassIncluding.new
221
245
  setting_class_including_instance.respond_to?( :some_configuration ).should == false
246
+ setting_class_including_instance.instance_variables.empty?.should == true
222
247
  # => instances of extending classes get nothing
223
248
  class ClassExtending
224
249
  extend CascadingConfiguration::Setting::ClassConfigurationMockIncluded
@@ -227,9 +252,11 @@ describe CascadingConfiguration::Setting do
227
252
  self.some_configuration = :some_other_configuration
228
253
  some_configuration.should == :some_other_configuration
229
254
  instance_methods.include?( :some_configuration ).should == false
255
+ instance_variables.empty?.should == true
230
256
  end
231
257
  setting_class_including_instance = ClassExtending.new
232
258
  setting_class_including_instance.respond_to?( :some_configuration ).should == false
259
+ setting_class_including_instance.instance_variables.empty?.should == true
233
260
  end
234
261
 
235
262
  class CascadingConfiguration::Setting::ClassConfigurationMockClass
@@ -237,16 +264,19 @@ describe CascadingConfiguration::Setting do
237
264
  some_configuration.should == :another_configuration
238
265
  self.some_configuration = :our_setting_value
239
266
  some_configuration.should == :our_setting_value
267
+ instance_variables.empty?.should == true
240
268
  end
241
269
  class CascadingConfiguration::Setting::ClassConfigurationMockClassSub1 < CascadingConfiguration::Setting::ClassConfigurationMockClass
242
270
  some_configuration.should == :our_setting_value
243
271
  self.some_configuration = :our_other_setting_value
244
272
  some_configuration.should == :our_other_setting_value
273
+ instance_variables.empty?.should == true
245
274
  end
246
275
  class CascadingConfiguration::Setting::ClassConfigurationMockClassSub2 < CascadingConfiguration::Setting::ClassConfigurationMockClassSub1
247
276
  some_configuration.should == :our_other_setting_value
248
277
  self.some_configuration = :a_third_setting_value
249
278
  some_configuration.should == :a_third_setting_value
279
+ instance_variables.empty?.should == true
250
280
  end
251
281
  end
252
282
 
@@ -273,28 +303,33 @@ describe CascadingConfiguration::Setting do
273
303
  self.some_configuration = :our_setting_value
274
304
  some_configuration.should == :our_setting_value
275
305
  instance_methods.include?( :some_configuration ).should == false
306
+ instance_variables.empty?.should == true
276
307
  # => including modules and classes get nothing
277
308
  module SubmoduleIncluding
278
309
  include CascadingConfiguration::Setting::LocalConfigurationMockExtended
279
310
  instance_methods.include?( :some_configuration ).should == false
280
311
  respond_to?( :some_configuration ).should == false
312
+ instance_variables.empty?.should == true
281
313
  end
282
314
  # => extending modules and classes get nothing
283
315
  module SubmoduleExtending
284
316
  extend CascadingConfiguration::Setting::LocalConfigurationMockExtended
285
317
  instance_methods.include?( :some_configuration ).should == false
286
318
  respond_to?( :some_configuration ).should == false
319
+ instance_variables.empty?.should == true
287
320
  end
288
321
  # => instances of including and extending classes get nothing
289
322
  class ClassIncluding
290
323
  include CascadingConfiguration::Setting::LocalConfigurationMockExtended
291
324
  instance_methods.include?( :some_configuration ).should == false
292
325
  respond_to?( :some_configuration ).should == false
326
+ instance_variables.empty?.should == true
293
327
  end
294
328
  class ClassExtending
295
329
  extend CascadingConfiguration::Setting::LocalConfigurationMockExtended
296
330
  instance_methods.include?( :some_configuration ).should == false
297
331
  respond_to?( :some_configuration ).should == false
332
+ instance_variables.empty?.should == true
298
333
  end
299
334
  end
300
335
 
@@ -308,11 +343,13 @@ describe CascadingConfiguration::Setting do
308
343
  self.some_configuration = :our_setting_value
309
344
  some_configuration.should == :our_setting_value
310
345
  instance_methods.include?( :some_configuration ).should == false
346
+ instance_variables.empty?.should == true
311
347
  # => including modules and classes get attr_configuration and configurations
312
348
  module SubmoduleIncluding
313
349
  include CascadingConfiguration::Setting::LocalConfigurationMockIncluded
314
350
  instance_methods.include?( :some_configuration ).should == false
315
351
  respond_to?( :some_configuration ).should == false
352
+ instance_variables.empty?.should == true
316
353
  end
317
354
  # => extending modules and classes get attr_configuration and configurations
318
355
  module SubmoduleExtending
@@ -322,34 +359,42 @@ describe CascadingConfiguration::Setting do
322
359
  # - the rest of the ancestors will be the extending module's include chain
323
360
  respond_to?( :some_configuration ).should == false
324
361
  instance_methods.include?( :some_configuration ).should == false
362
+ instance_variables.empty?.should == true
325
363
  end
326
364
  # => instances of including classes get configurations
327
365
  class ClassIncluding
328
366
  include CascadingConfiguration::Setting::LocalConfigurationMockIncluded
329
367
  instance_methods.include?( :some_configuration ).should == false
330
368
  respond_to?( :some_configuration ).should == false
369
+ instance_variables.empty?.should == true
331
370
  end
332
371
  setting_class_including_instance = ClassIncluding.new
333
372
  setting_class_including_instance.respond_to?( :some_configuration ).should == false
373
+ setting_class_including_instance.instance_variables.empty?.should == true
334
374
  # => instances of extending classes get nothing
335
375
  class ClassExtending
336
376
  extend CascadingConfiguration::Setting::LocalConfigurationMockIncluded
337
377
  respond_to?( :some_configuration ).should == false
338
378
  instance_methods.include?( :some_configuration ).should == false
379
+ instance_variables.empty?.should == true
339
380
  end
340
381
  setting_class_including_instance = ClassExtending.new
341
382
  setting_class_including_instance.respond_to?( :some_configuration ).should == false
383
+ setting_class_including_instance.instance_variables.empty?.should == true
342
384
  end
343
385
 
344
386
  class CascadingConfiguration::Setting::LocalConfigurationMockClass
345
387
  include CascadingConfiguration::Setting::LocalConfigurationMockIncluded::SubmoduleIncluding
346
388
  respond_to?( :some_configuration ).should == false
389
+ instance_variables.empty?.should == true
347
390
  end
348
391
  class CascadingConfiguration::Setting::LocalConfigurationMockClassSub1 < CascadingConfiguration::Setting::LocalConfigurationMockClass
349
392
  respond_to?( :some_configuration ).should == false
393
+ instance_variables.empty?.should == true
350
394
  end
351
395
  class CascadingConfiguration::Setting::LocalConfigurationMockClassSub2 < CascadingConfiguration::Setting::LocalConfigurationMockClassSub1
352
396
  respond_to?( :some_configuration ).should == false
397
+ instance_variables.empty?.should == true
353
398
  end
354
399
  end
355
400
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 2
8
- - 1
9
- version: 1.2.1
8
+ - 2
9
+ version: 1.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Asher
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-07-19 00:00:00 -04:00
17
+ date: 2011-07-20 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency