cascading-configuration-setting 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,24 +1,21 @@
1
1
 
2
- if $cascading_configuration_development
3
- require_relative '../../variable/lib/cascading-configuration-variable.rb'
4
- else
5
- require 'cascading-configuration-variable'
6
- end
2
+ require 'cascading-configuration-variable'
3
+ #require_relative '../../variable/lib/cascading-configuration-variable.rb'
7
4
 
8
5
  module CascadingConfiguration
9
6
  module Setting
10
- module AccessorDefinitionMethods
7
+ class CompositingHash < ::Hash
8
+ class LocalConfigurationHash < ::Hash
9
+ end
11
10
  end
12
11
  module Interface
13
- module Instance
12
+ module GettersSetters
14
13
  end
15
14
  end
16
- module ObjectInstance
17
- end
18
15
  end
19
16
  end
20
17
 
21
- require_relative 'cascading-configuration-setting/CascadingConfiguration/Setting.rb'
22
- require_relative 'cascading-configuration-setting/CascadingConfiguration/Setting/AccessorDefinitionMethods.rb'
18
+ require_relative 'cascading-configuration-setting/_private_/CascadingConfiguration/Setting/Interface/GettersSetters.rb'
19
+
23
20
  require_relative 'cascading-configuration-setting/CascadingConfiguration/Setting/Interface.rb'
24
- require_relative 'cascading-configuration-setting/CascadingConfiguration/Setting/Interface/Instance.rb'
21
+ require_relative 'cascading-configuration-setting/CascadingConfiguration/Setting.rb'
@@ -1,45 +1,10 @@
1
1
 
2
2
  module CascadingConfiguration::Setting
3
-
4
- extend ModuleCluster
5
-
6
- extend CascadingConfiguration::InternalModuleStub
7
-
8
- include CascadingConfiguration::Variable
9
- include CascadingConfiguration::Setting::Interface
10
- include CascadingConfiguration::Setting::AccessorDefinitionMethods
11
-
12
- prepend_module_include do |class_or_module|
13
- class_or_module.extend_also_extends( CascadingConfiguration::Variable::EigenclassConfigurationChain )
14
- end
15
-
16
- include_cascades_extends( CascadingConfiguration::Setting::Interface::Instance )
17
3
 
18
- include_cascades_extends( CascadingConfiguration::Setting )
4
+ # Configuration modules for storage of settings variables
5
+ include ::CascadingConfiguration::Variable
19
6
 
20
- prepend_module_include do |class_or_module|
21
- class_or_module.include_or_extend_cascades_prepending_extends do
22
- accessor_module_support
23
- end
24
- end
25
-
26
- ########################################
27
- # get_configuration_searching_upward #
28
- ########################################
29
-
30
- def get_configuration_searching_upward( configuration_name )
31
-
32
- configuration = nil
33
-
34
- ancestor_configuration_chain.each do |this_ancestor|
35
- if accessor_module_support.has_configuration_variable?( this_ancestor, configuration_name )
36
- configuration = accessor_module_support.get_configuration_variable( this_ancestor, configuration_name )
37
- break
38
- end
39
- end
40
-
41
- return configuration
42
-
43
- end
7
+ # Interface to declare configuration settings
8
+ include ::CascadingConfiguration::Setting::Interface
44
9
 
45
10
  end
@@ -1,7 +1,8 @@
1
1
 
2
2
  module CascadingConfiguration::Setting::Interface
3
3
 
4
- extend CascadingConfiguration::InternalModuleStub
4
+ # Support methods that define configuration setting methods
5
+ include CascadingConfiguration::Setting::Interface::GettersSetters
5
6
 
6
7
  ########################
7
8
  # attr_configuration #
@@ -9,13 +10,17 @@ module CascadingConfiguration::Setting::Interface
9
10
 
10
11
  # defines configuration in class or module
11
12
  # configuration cascades downward to instance including all classes or modules in-between
12
- def attr_configuration( *property_names )
13
- property_names.each do |this_property_name|
13
+ def attr_configuration( *configuration_names )
14
+
15
+ configuration_names.each do |this_configuration_name|
14
16
  # define configuration setter
15
- define_cascading_setter( this_property_name )
17
+ define_cascading_setter( this_configuration_name )
16
18
  # define configuration getter
17
- define_cascading_getter( this_property_name )
19
+ define_cascading_getter( this_configuration_name )
18
20
  end
21
+
22
+ return self
23
+
19
24
  end
20
25
 
21
26
  ###############################
@@ -24,13 +29,17 @@ module CascadingConfiguration::Setting::Interface
24
29
 
25
30
  # defines configuration in class or module
26
31
  # configuration cascades downward to last class or module
27
- def attr_module_configuration( *property_names )
28
- property_names.each do |this_property_name|
32
+ def attr_module_configuration( *configuration_names )
33
+
34
+ configuration_names.each do |this_configuration_name|
29
35
  # define configuration setter
30
- define_class_configuration_setter( this_property_name )
36
+ define_class_configuration_setter( this_configuration_name )
31
37
  # define configuration getter
32
- define_class_configuration_getter( this_property_name )
38
+ define_class_configuration_getter( this_configuration_name )
33
39
  end
40
+
41
+ return self
42
+
34
43
  end
35
44
  alias_method :attr_class_configuration, :attr_module_configuration
36
45
 
@@ -42,15 +51,19 @@ module CascadingConfiguration::Setting::Interface
42
51
  # also local to instances of class or module
43
52
  # * any instances of class
44
53
  # * first class to include module (inherited)
45
- def attr_local_configuration( *property_names )
46
- CascadingConfiguration::Variable.define_accessor_local_instance_support( self )
47
- property_names.each do |this_property_name|
54
+ def attr_local_configuration( *configuration_names )
55
+
56
+ CascadingConfiguration::Variable.initialize_local_instance_configuration_module( self )
57
+
58
+ configuration_names.each do |this_configuration_name|
48
59
  # define configuration setter
49
- define_local_configuration_setter( this_property_name )
60
+ define_local_configuration_setter( this_configuration_name )
50
61
  # define configuration getter
51
- define_local_configuration_getter( this_property_name )
62
+ define_local_configuration_getter( this_configuration_name )
52
63
  end
53
- CascadingConfiguration::Variable.cascade_local_instance( self )
64
+
65
+ return self
66
+
54
67
  end
55
68
 
56
69
  ###############################
@@ -59,14 +72,39 @@ module CascadingConfiguration::Setting::Interface
59
72
 
60
73
  # local to class or module or instance that declares it
61
74
  # * only in the instance that declares it
62
- def attr_object_configuration( *property_names )
63
- CascadingConfiguration::Variable.define_accessor_local_instance_support( self )
64
- property_names.each do |this_property_name|
75
+ def attr_object_configuration( *configuration_names )
76
+
77
+ CascadingConfiguration::Variable.initialize_local_instance_configuration_module( self )
78
+
79
+ configuration_names.each do |this_configuration_name|
65
80
  # define configuration setter
66
- define_object_configuration_setter( this_property_name )
81
+ define_object_configuration_setter( this_configuration_name )
67
82
  # define configuration getter
68
- define_object_configuration_getter( this_property_name )
83
+ define_object_configuration_getter( this_configuration_name )
69
84
  end
85
+
86
+ return self
87
+
88
+ end
89
+
90
+ #################################
91
+ # attr_instance_configuration #
92
+ #################################
93
+
94
+ # local to class or module or instance that declares it
95
+ # * in instances of the class or module that declares it
96
+ # * in instance if declared on non-class/non-module object instance
97
+ def attr_instance_configuration( *configuration_names )
98
+
99
+ configuration_names.each do |this_configuration_name|
100
+ # define configuration setter
101
+ define_instance_configuration_setter( this_configuration_name )
102
+ # define configuration getter
103
+ define_instance_configuration_getter( this_configuration_name )
104
+ end
105
+
106
+ return self
107
+
70
108
  end
71
109
 
72
110
  end
@@ -0,0 +1,298 @@
1
+
2
+ module CascadingConfiguration::Setting::Interface::GettersSetters
3
+
4
+ #############################
5
+ # define_cascading_setter #
6
+ #############################
7
+
8
+ def define_cascading_setter( configuration_name )
9
+
10
+ configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
11
+
12
+ module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
13
+ instance_configuration_support_module = CascadingConfiguration::Variable.instance_configuration_support_module( self )
14
+
15
+ module_configuration_support_module.module_eval do
16
+ define_method( configuration_setter_name ) do |value|
17
+
18
+ # we define in one module but set in the local module where the method is _used_ not defined
19
+ self_module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
20
+
21
+ # configuration setter returns setting variable (variable from self), which is now the ID of value
22
+ return self_module_configuration_support_module.set_configuration_variable( configuration_name, value )
23
+
24
+ end
25
+ end
26
+
27
+ instance_configuration_support_module.module_eval do
28
+ define_method( configuration_setter_name ) do |value|
29
+
30
+ # we define in one module but set in the local module where the method is _used_ not defined
31
+ self_module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
32
+
33
+ if for_instance = ! is_a?( Module ) and ! self_module_configuration_support_module
34
+ self_module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self.class )
35
+ end
36
+
37
+ # configuration setter returns setting variable (variable from self), which is now the ID of value
38
+ return self_module_configuration_support_module.set_configuration_variable( configuration_name, value, for_instance )
39
+
40
+ end
41
+ end if instance_configuration_support_module
42
+
43
+ end
44
+
45
+ #############################
46
+ # define_cascading_getter #
47
+ #############################
48
+
49
+ def define_cascading_getter( configuration_name )
50
+
51
+ configuration_getter_name = configuration_name
52
+
53
+ module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
54
+ instance_configuration_support_module = CascadingConfiguration::Variable.instance_configuration_support_module( self )
55
+
56
+ module_configuration_support_module.module_eval do
57
+ define_method( configuration_getter_name ) do
58
+
59
+ self_module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
60
+
61
+ # configuration getter returns current setting value (taken from first superclass with setting)
62
+ # that means first variable that has been set
63
+ return self_module_configuration_support_module.get_configuration_searching_upward( configuration_name )
64
+
65
+ end
66
+ end
67
+
68
+ instance_configuration_support_module.module_eval do
69
+ define_method( configuration_getter_name ) do
70
+
71
+ self_module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
72
+
73
+ if for_instance = ! is_a?( Module ) and ! self_module_configuration_support_module
74
+ self_module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self.class )
75
+ end
76
+
77
+ # configuration getter returns current setting value (taken from first superclass with setting)
78
+ # that means first variable that has been set
79
+ return self_module_configuration_support_module.get_configuration_searching_upward( configuration_name, for_instance )
80
+
81
+ end
82
+ end if instance_configuration_support_module
83
+
84
+ end
85
+
86
+ #######################################
87
+ # define_class_configuration_setter #
88
+ #######################################
89
+
90
+ def define_class_configuration_setter( configuration_name )
91
+
92
+ configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
93
+
94
+ module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
95
+
96
+ module_configuration_support_module.module_eval do
97
+ define_method( configuration_setter_name ) do |value|
98
+
99
+ # we define in one module but set in the local module where the method is _used_ not defined
100
+ module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
101
+
102
+ # configuration setter returns setting variable (variable from self), which is now the ID of value
103
+ return module_configuration_support_module.set_configuration_variable( configuration_name, value )
104
+
105
+ end
106
+ end
107
+
108
+ end
109
+
110
+ #######################################
111
+ # define_class_configuration_getter #
112
+ #######################################
113
+
114
+ def define_class_configuration_getter( configuration_name )
115
+
116
+ configuration_getter_name = configuration_name
117
+
118
+ module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
119
+
120
+ module_configuration_support_module.module_eval do
121
+ define_method( configuration_getter_name ) do
122
+
123
+ # we define in one module but set in the local module where the method is _used_ not defined
124
+ self_module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
125
+
126
+ # configuration getter returns current setting value (taken from first superclass with setting)
127
+ # that means first variable that has been set
128
+ return self_module_configuration_support_module.get_configuration_searching_upward( configuration_name )
129
+
130
+ end
131
+ end
132
+
133
+ end
134
+
135
+ #######################################
136
+ # define_local_configuration_setter #
137
+ #######################################
138
+
139
+ def define_local_configuration_setter( configuration_name )
140
+
141
+ configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
142
+
143
+ instance_configuration_support_module = CascadingConfiguration::Variable.instance_configuration_support_module( self )
144
+
145
+ local_instance_configuration_support_module = CascadingConfiguration::Variable.local_instance_configuration_support_module( self )
146
+
147
+ local_setter_proc = Proc.new do |value|
148
+
149
+ # we define in one module but set in the local module where the method is _used_ not defined
150
+ module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
151
+
152
+ # configuration setter returns setting variable (variable from self), which is now the ID of value
153
+ return module_configuration_support_module.set_configuration_variable( configuration_name, value )
154
+
155
+ end
156
+
157
+ instance_configuration_support_module.module_eval do
158
+ define_method( configuration_setter_name, & local_setter_proc )
159
+ end if instance_configuration_support_module
160
+
161
+ local_instance_configuration_support_module.module_eval do
162
+ define_method( configuration_setter_name, & local_setter_proc )
163
+ end
164
+
165
+ end
166
+
167
+ #######################################
168
+ # define_local_configuration_getter #
169
+ #######################################
170
+
171
+ def define_local_configuration_getter( configuration_name )
172
+
173
+ configuration_getter_name = configuration_name
174
+
175
+ instance_configuration_support_module = CascadingConfiguration::Variable.instance_configuration_support_module( self )
176
+
177
+ local_instance_configuration_support_module = CascadingConfiguration::Variable.local_instance_configuration_support_module( self )
178
+
179
+ local_getter_proc = Proc.new do
180
+
181
+ # we define in one module but set in the local module where the method is _used_ not defined
182
+ module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
183
+
184
+ # configuration getter returns current setting value (taken from first superclass with setting)
185
+ # that means first variable that has been set
186
+ return module_configuration_support_module.get_configuration_variable( configuration_name )
187
+
188
+ end
189
+
190
+ instance_configuration_support_module.module_eval do
191
+ define_method( configuration_getter_name, & local_getter_proc )
192
+ end if instance_configuration_support_module
193
+
194
+ local_instance_configuration_support_module.module_eval do
195
+ define_method( configuration_getter_name, & local_getter_proc )
196
+ end
197
+
198
+ end
199
+
200
+ ##########################################
201
+ # define_instance_configuration_setter #
202
+ ##########################################
203
+
204
+ def define_instance_configuration_setter( configuration_name )
205
+
206
+ configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
207
+
208
+ instance_configuration_support_module = CascadingConfiguration::Variable.instance_configuration_support_module( self )
209
+
210
+ instance_configuration_support_module.module_eval do
211
+ define_method( configuration_setter_name ) do |value|
212
+
213
+ # we define in one module but set in the local module where the method is _used_ not defined
214
+ module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
215
+
216
+ # configuration setter returns setting variable (variable from self), which is now the ID of value
217
+ return module_configuration_support_module.set_configuration_variable( configuration_name, value )
218
+
219
+ end
220
+ end
221
+
222
+ end
223
+
224
+ ##########################################
225
+ # define_instance_configuration_getter #
226
+ ##########################################
227
+
228
+ def define_instance_configuration_getter( configuration_name )
229
+
230
+ configuration_getter_name = configuration_name
231
+
232
+ instance_configuration_support_module = CascadingConfiguration::Variable.instance_configuration_support_module( self )
233
+
234
+ instance_configuration_support_module.module_eval do
235
+ define_method( configuration_getter_name ) do
236
+
237
+ # we define in one module but set in the local module where the method is _used_ not defined
238
+ module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
239
+
240
+ # configuration getter returns current setting value (taken from first superclass with setting)
241
+ # that means first variable that has been set
242
+ return module_configuration_support_module.get_configuration_variable( configuration_name )
243
+
244
+ end
245
+ end
246
+
247
+ end
248
+
249
+ ########################################
250
+ # define_object_configuration_setter #
251
+ ########################################
252
+
253
+ def define_object_configuration_setter( configuration_name )
254
+
255
+ configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
256
+
257
+ local_instance_configuration_support_module = CascadingConfiguration::Variable.local_instance_configuration_support_module( self )
258
+
259
+ local_instance_configuration_support_module.module_eval do
260
+ define_method( configuration_setter_name ) do |value|
261
+
262
+ # we define in one module but set in the local module where the method is _used_ not defined
263
+ module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
264
+
265
+ # configuration setter returns setting variable (variable from self), which is now the ID of value
266
+ return module_configuration_support_module.set_configuration_variable( configuration_name, value )
267
+
268
+ end
269
+ end
270
+
271
+ end
272
+
273
+ ########################################
274
+ # define_object_configuration_getter #
275
+ ########################################
276
+
277
+ def define_object_configuration_getter( configuration_name )
278
+
279
+ configuration_getter_name = configuration_name
280
+
281
+ local_instance_configuration_support_module = CascadingConfiguration::Variable.local_instance_configuration_support_module( self )
282
+
283
+ local_instance_configuration_support_module.module_eval do
284
+ define_method( configuration_getter_name ) do
285
+
286
+ # we define in one module but set in the local module where the method is _used_ not defined
287
+ module_configuration_support_module = CascadingConfiguration::Variable.module_configuration_support_module( self )
288
+
289
+ # configuration getter returns current setting value (taken from first superclass with setting)
290
+ # that means first variable that has been set
291
+ return module_configuration_support_module.get_configuration_variable( configuration_name )
292
+
293
+ end
294
+ end
295
+
296
+ end
297
+
298
+ end
@@ -141,6 +141,24 @@ describe CascadingConfiguration::Setting do
141
141
  some_configuration.should == :a_third_setting_value
142
142
  instance_variables.empty?.should == true
143
143
  end
144
+
145
+ module SomeModule
146
+ include CascadingConfiguration::Setting
147
+ attr_configuration :some_configuration
148
+ self.some_configuration = :another_configuration
149
+ end
150
+ module OtherModule
151
+ include SomeModule
152
+ end
153
+ Object.new.instance_eval do
154
+ extend( OtherModule )
155
+ respond_to?( :some_configuration ).should == true
156
+ some_configuration.should == :another_configuration
157
+ self.some_configuration = :our_setting_value
158
+ some_configuration.should == :our_setting_value
159
+ instance_variables.empty?.should == true
160
+ end
161
+
144
162
  end
145
163
 
146
164
  ###############################
@@ -280,6 +298,7 @@ describe CascadingConfiguration::Setting do
280
298
  some_configuration.should == :a_third_setting_value
281
299
  instance_variables.empty?.should == true
282
300
  end
301
+
283
302
  end
284
303
 
285
304
  ##############################
@@ -350,13 +369,13 @@ describe CascadingConfiguration::Setting do
350
369
  module SubmoduleIncluding
351
370
  include CascadingConfiguration::Setting::LocalConfigurationMockIncluded
352
371
  instance_methods.include?( :some_configuration ).should == true
353
- respond_to?( :some_configuration ).should == true
372
+ respond_to?( :some_configuration ).should == false
354
373
  instance_variables.empty?.should == true
355
374
  end
356
375
  module SubSubmoduleIncluding
357
376
  include CascadingConfiguration::Setting::LocalConfigurationMockIncluded::SubmoduleIncluding
358
377
  instance_methods.include?( :some_configuration ).should == true
359
- respond_to?( :some_configuration ).should == true
378
+ respond_to?( :some_configuration ).should == false
360
379
  instance_variables.empty?.should == true
361
380
  end
362
381
  # => extending modules and classes get attr_configuration and configurations
@@ -382,7 +401,7 @@ describe CascadingConfiguration::Setting do
382
401
  class ClassIncluding
383
402
  include CascadingConfiguration::Setting::LocalConfigurationMockIncluded
384
403
  instance_methods.include?( :some_configuration ).should == true
385
- respond_to?( :some_configuration ).should == true
404
+ respond_to?( :some_configuration ).should == false
386
405
  instance_variables.empty?.should == true
387
406
  end
388
407
  setting_class_including_instance = ClassIncluding.new
@@ -454,7 +473,7 @@ describe CascadingConfiguration::Setting do
454
473
  module CascadingConfiguration::Setting::InstanceConfigurationMockExtended
455
474
  extend CascadingConfiguration::Setting
456
475
  # => singleton gets attr_configuration and configurations
457
- respond_to?( :attr_instance_configuration ).should == false
476
+ respond_to?( :attr_instance_configuration ).should == true
458
477
  instance_methods.include?( :some_configuration ).should == false
459
478
  instance_variables.empty?.should == true
460
479
  # => including modules and classes get nothing
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cascading-configuration-setting
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 4
8
- - 1
9
- version: 1.4.1
4
+ prerelease:
5
+ version: 1.5.0
10
6
  platform: ruby
11
7
  authors:
12
8
  - Asher
@@ -14,8 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-08-08 00:00:00 -04:00
18
- default_executable:
13
+ date: 2012-01-16 00:00:00 Z
19
14
  dependencies:
20
15
  - !ruby/object:Gem::Dependency
21
16
  name: module-cluster
@@ -25,8 +20,6 @@ dependencies:
25
20
  requirements:
26
21
  - - ">="
27
22
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
23
  version: "0"
31
24
  type: :runtime
32
25
  version_requirements: *id001
@@ -38,8 +31,6 @@ dependencies:
38
31
  requirements:
39
32
  - - ">="
40
33
  - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
34
  version: "0"
44
35
  type: :runtime
45
36
  version_requirements: *id002
@@ -52,16 +43,13 @@ extensions: []
52
43
  extra_rdoc_files: []
53
44
 
54
45
  files:
55
- - lib/cascading-configuration-setting/CascadingConfiguration/Setting/AccessorDefinitionMethods.rb
56
- - lib/cascading-configuration-setting/CascadingConfiguration/Setting/Interface/Instance.rb
46
+ - lib/cascading-configuration-setting/_private_/CascadingConfiguration/Setting/Interface/GettersSetters.rb
57
47
  - lib/cascading-configuration-setting/CascadingConfiguration/Setting/Interface.rb
58
48
  - lib/cascading-configuration-setting/CascadingConfiguration/Setting.rb
59
49
  - lib/cascading-configuration-setting.rb
60
- - spec/CascadingConfiguration/Setting/AccessorDefinitionMethods_spec.rb
61
50
  - spec/CascadingConfiguration/Setting_spec.rb
62
51
  - README.md
63
52
  - README.rdoc
64
- has_rdoc: true
65
53
  homepage: http://rubygems.org/gems/cascading-configuration-setting
66
54
  licenses: []
67
55
 
@@ -75,21 +63,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
63
  requirements:
76
64
  - - ">="
77
65
  - !ruby/object:Gem::Version
78
- segments:
79
- - 0
80
66
  version: "0"
81
67
  required_rubygems_version: !ruby/object:Gem::Requirement
82
68
  none: false
83
69
  requirements:
84
70
  - - ">="
85
71
  - !ruby/object:Gem::Version
86
- segments:
87
- - 0
88
72
  version: "0"
89
73
  requirements: []
90
74
 
91
75
  rubyforge_project: cascading-configuration-setting
92
- rubygems_version: 1.3.7
76
+ rubygems_version: 1.8.10
93
77
  signing_key:
94
78
  specification_version: 3
95
79
  summary: Support package for cascading-configuration.
@@ -1,159 +0,0 @@
1
-
2
- module CascadingConfiguration::Setting::AccessorDefinitionMethods
3
-
4
- extend CascadingConfiguration::InternalModuleStub
5
-
6
- #############################
7
- # define_cascading_setter #
8
- #############################
9
-
10
- def define_cascading_setter( configuration_name )
11
- configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
12
- [ accessor_instance_support, accessor_module_support ].compact.each do |module_support|
13
- module_support.module_eval do
14
- define_method( configuration_setter_name ) do |value|
15
- # configuration setter returns setting variable (variable from self), which is now the ID of value
16
- return accessor_module_support.set_configuration_variable( self, configuration_name, value )
17
- end
18
- end
19
- end
20
- end
21
-
22
- #############################
23
- # define_cascading_getter #
24
- #############################
25
-
26
- def define_cascading_getter( configuration_name )
27
- configuration_getter_name = configuration_name
28
- [ accessor_instance_support, accessor_module_support ].compact.each do |module_support|
29
- module_support.module_eval do
30
- define_method( configuration_getter_name ) do
31
- # configuration getter returns current setting value (taken from first superclass with setting)
32
- # that means first variable that has been set
33
- return get_configuration_searching_upward( configuration_name )
34
- end
35
- end
36
- end
37
- end
38
-
39
- #######################################
40
- # define_class_configuration_setter #
41
- #######################################
42
-
43
- def define_class_configuration_setter( configuration_name )
44
- configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
45
- accessor_module_support.module_eval do
46
- define_method( configuration_setter_name ) do |value|
47
- # configuration setter returns setting variable (variable from self), which is now the ID of value
48
- return accessor_module_support.set_configuration_variable( self, configuration_name, value )
49
- end
50
- end
51
- end
52
-
53
- #######################################
54
- # define_class_configuration_getter #
55
- #######################################
56
-
57
- def define_class_configuration_getter( configuration_name )
58
- configuration_getter_name = configuration_name
59
- accessor_module_support.module_eval do
60
- define_method( configuration_getter_name ) do
61
- # configuration getter returns current setting value (taken from first superclass with setting)
62
- # that means first variable that has been set
63
- return get_configuration_searching_upward( configuration_name )
64
- end
65
- end
66
- end
67
-
68
- #######################################
69
- # define_local_configuration_setter #
70
- #######################################
71
-
72
- def define_local_configuration_setter( configuration_name )
73
- configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
74
- [ accessor_instance_support, accessor_local_instance_support ].compact.each do |module_support|
75
- module_support.module_eval do
76
- define_method( configuration_setter_name ) do |value|
77
- # configuration setter returns setting variable (variable from self), which is now the ID of value
78
- return accessor_module_support.set_configuration_variable( self, configuration_name, value )
79
- end
80
- end
81
- end
82
- end
83
-
84
- #######################################
85
- # define_local_configuration_getter #
86
- #######################################
87
-
88
- def define_local_configuration_getter( configuration_name )
89
- configuration_getter_name = configuration_name
90
- [ accessor_instance_support, accessor_local_instance_support ].compact.each do |module_support|
91
- module_support.module_eval do
92
- define_method( configuration_getter_name ) do
93
- # configuration getter returns current setting value (taken from first superclass with setting)
94
- # that means first variable that has been set
95
- return accessor_module_support.get_configuration_variable( self, configuration_name )
96
- end
97
- end
98
- end
99
- end
100
-
101
- ##########################################
102
- # define_instance_configuration_setter #
103
- ##########################################
104
-
105
- def define_instance_configuration_setter( configuration_name )
106
- configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
107
- accessor_instance_support.module_eval do
108
- define_method( configuration_setter_name ) do |value|
109
- # configuration setter returns setting variable (variable from self), which is now the ID of value
110
- return accessor_module_support.set_configuration_variable( self, configuration_name, value )
111
- end
112
- end
113
- end
114
-
115
- ##########################################
116
- # define_instance_configuration_getter #
117
- ##########################################
118
-
119
- def define_instance_configuration_getter( configuration_name )
120
- configuration_getter_name = configuration_name
121
- accessor_instance_support.module_eval do
122
- define_method( configuration_getter_name ) do
123
- # configuration getter returns current setting value (taken from first superclass with setting)
124
- # that means first variable that has been set
125
- return accessor_module_support.get_configuration_variable( self, configuration_name )
126
- end
127
- end
128
- end
129
-
130
- ########################################
131
- # define_object_configuration_setter #
132
- ########################################
133
-
134
- def define_object_configuration_setter( configuration_name )
135
- configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
136
- accessor_local_instance_support.module_eval do
137
- define_method( configuration_setter_name ) do |value|
138
- # configuration setter returns setting variable (variable from self), which is now the ID of value
139
- return accessor_module_support.set_configuration_variable( self, configuration_name, value )
140
- end
141
- end
142
- end
143
-
144
- ########################################
145
- # define_object_configuration_getter #
146
- ########################################
147
-
148
- def define_object_configuration_getter( configuration_name )
149
- configuration_getter_name = configuration_name
150
- accessor_local_instance_support.module_eval do
151
- define_method( configuration_getter_name ) do
152
- # configuration getter returns current setting value (taken from first superclass with setting)
153
- # that means first variable that has been set
154
- return accessor_module_support.get_configuration_variable( self, configuration_name )
155
- end
156
- end
157
- end
158
-
159
- end
@@ -1,23 +0,0 @@
1
-
2
- module CascadingConfiguration::Setting::Interface::Instance
3
-
4
- extend CascadingConfiguration::InternalModuleStub
5
-
6
- #################################
7
- # attr_instance_configuration #
8
- #################################
9
-
10
- # local to class or module or instance that declares it
11
- # * in instances of the class or module that declares it
12
- # * in instance if declared on non-class/non-module object instance
13
- def attr_instance_configuration( *property_names )
14
- property_names.each do |this_property_name|
15
- # define configuration setter
16
- define_instance_configuration_setter( this_property_name )
17
- # define configuration getter
18
- define_instance_configuration_getter( this_property_name )
19
- end
20
- return self
21
- end
22
-
23
- end
@@ -1,29 +0,0 @@
1
-
2
- require_relative '../../../lib/cascading-configuration-setting.rb'
3
-
4
- describe CascadingConfiguration::Setting::AccessorDefinitionMethods do
5
-
6
- #############################
7
- # define_cascading_setter #
8
- # define_cascading_getter #
9
- #############################
10
-
11
- it 'can define a method to get and set configuration value' do
12
- class CascadingConfiguration::Setting::Mock
13
- include CascadingConfiguration::Setting
14
- end
15
- # setter
16
- setter_method_name = ( :some_configuration.to_s + '=' ).to_sym
17
- CascadingConfiguration::Setting::Mock.define_cascading_setter( :some_configuration )
18
- CascadingConfiguration::Setting::Mock.methods.include?( setter_method_name ).should == true
19
- CascadingConfiguration::Setting::Mock.instance_methods.include?( setter_method_name ).should == true
20
- CascadingConfiguration::Setting::Mock.some_configuration = :a_setting_not_yet_used
21
- CascadingConfiguration::Setting::Mock.accessor_module_support.get_configuration_variable( CascadingConfiguration::Setting::Mock, :some_configuration ).should == :a_setting_not_yet_used
22
- # getter
23
- CascadingConfiguration::Setting::Mock.define_cascading_getter( :some_configuration )
24
- CascadingConfiguration::Setting::Mock.methods.include?( :some_configuration ).should == true
25
- CascadingConfiguration::Setting::Mock.instance_methods.include?( :some_configuration ).should == true
26
- CascadingConfiguration::Setting::Mock.some_configuration.should == :a_setting_not_yet_used
27
- end
28
-
29
- end