cascading-configuration-setting 1.5.1 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -53,7 +53,7 @@ module CascadingConfiguration::Setting::Interface
|
|
53
53
|
# * first class to include module (inherited)
|
54
54
|
def attr_local_configuration( *configuration_names )
|
55
55
|
|
56
|
-
CascadingConfiguration::Variable.
|
56
|
+
CascadingConfiguration::Variable::ConfigurationSupport.create_local_instance_configuration_support_module( self )
|
57
57
|
|
58
58
|
configuration_names.each do |this_configuration_name|
|
59
59
|
# define configuration setter
|
@@ -74,7 +74,7 @@ module CascadingConfiguration::Setting::Interface
|
|
74
74
|
# * only in the instance that declares it
|
75
75
|
def attr_object_configuration( *configuration_names )
|
76
76
|
|
77
|
-
CascadingConfiguration::Variable.
|
77
|
+
CascadingConfiguration::Variable::ConfigurationSupport.create_local_instance_configuration_support_module( self )
|
78
78
|
|
79
79
|
configuration_names.each do |this_configuration_name|
|
80
80
|
# define configuration setter
|
@@ -1,6 +1,8 @@
|
|
1
1
|
|
2
2
|
module CascadingConfiguration::Setting::Interface::GettersSetters
|
3
3
|
|
4
|
+
ConfigurationSupport = ::CascadingConfiguration::Variable::ConfigurationSupport
|
5
|
+
|
4
6
|
#############################
|
5
7
|
# define_cascading_setter #
|
6
8
|
#############################
|
@@ -9,35 +11,19 @@ module CascadingConfiguration::Setting::Interface::GettersSetters
|
|
9
11
|
|
10
12
|
configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
|
11
13
|
|
12
|
-
|
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 )
|
14
|
+
configuration_support_module = ::CascadingConfiguration::Variable::ConfigurationSupport.configuration_support_module( self )
|
15
|
+
instance_configuration_support_module = ::CascadingConfiguration::Variable::ConfigurationSupport.instance_configuration_support_module( self )
|
20
16
|
|
21
|
-
|
22
|
-
|
17
|
+
setter_proc = Proc.new do |value|
|
18
|
+
::CascadingConfiguration::Variable::ConfigurationSupport.set_configuration_variable( self, configuration_name, value )
|
19
|
+
end
|
23
20
|
|
24
|
-
|
21
|
+
configuration_support_module.module_eval do
|
22
|
+
define_method( configuration_setter_name, & setter_proc )
|
25
23
|
end
|
26
|
-
|
24
|
+
|
27
25
|
instance_configuration_support_module.module_eval do
|
28
|
-
define_method( configuration_setter_name
|
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
|
26
|
+
define_method( configuration_setter_name, & setter_proc )
|
41
27
|
end if instance_configuration_support_module
|
42
28
|
|
43
29
|
end
|
@@ -50,35 +36,19 @@ module CascadingConfiguration::Setting::Interface::GettersSetters
|
|
50
36
|
|
51
37
|
configuration_getter_name = configuration_name
|
52
38
|
|
53
|
-
|
54
|
-
instance_configuration_support_module = CascadingConfiguration::Variable.instance_configuration_support_module( self )
|
39
|
+
configuration_support_module = ::CascadingConfiguration::Variable::ConfigurationSupport.configuration_support_module( self )
|
40
|
+
instance_configuration_support_module = ::CascadingConfiguration::Variable::ConfigurationSupport.instance_configuration_support_module( self )
|
55
41
|
|
56
|
-
|
57
|
-
|
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 )
|
42
|
+
getter_proc = Proc.new do
|
43
|
+
return ::CascadingConfiguration::Variable::ConfigurationSupport.get_configuration_searching_upward( self, configuration_name )
|
44
|
+
end
|
64
45
|
|
65
|
-
|
46
|
+
configuration_support_module.module_eval do
|
47
|
+
define_method( configuration_getter_name, & getter_proc )
|
66
48
|
end
|
67
|
-
|
49
|
+
|
68
50
|
instance_configuration_support_module.module_eval do
|
69
|
-
define_method( configuration_getter_name )
|
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
|
51
|
+
define_method( configuration_getter_name, & getter_proc )
|
82
52
|
end if instance_configuration_support_module
|
83
53
|
|
84
54
|
end
|
@@ -91,16 +61,15 @@ module CascadingConfiguration::Setting::Interface::GettersSetters
|
|
91
61
|
|
92
62
|
configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
|
93
63
|
|
94
|
-
|
64
|
+
configuration_support_module = ::CascadingConfiguration::Variable::ConfigurationSupport.configuration_support_module( self )
|
95
65
|
|
96
|
-
|
66
|
+
configuration_support_module.module_eval do
|
97
67
|
define_method( configuration_setter_name ) do |value|
|
98
68
|
|
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
69
|
# configuration setter returns setting variable (variable from self), which is now the ID of value
|
103
|
-
|
70
|
+
return ::CascadingConfiguration::Variable::ConfigurationSupport.set_configuration_variable( self,
|
71
|
+
configuration_name,
|
72
|
+
value )
|
104
73
|
|
105
74
|
end
|
106
75
|
end
|
@@ -115,17 +84,15 @@ module CascadingConfiguration::Setting::Interface::GettersSetters
|
|
115
84
|
|
116
85
|
configuration_getter_name = configuration_name
|
117
86
|
|
118
|
-
|
87
|
+
configuration_support_module = ::CascadingConfiguration::Variable::ConfigurationSupport.configuration_support_module( self )
|
119
88
|
|
120
|
-
|
89
|
+
configuration_support_module.module_eval do
|
121
90
|
define_method( configuration_getter_name ) do
|
122
91
|
|
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
92
|
# configuration getter returns current setting value (taken from first superclass with setting)
|
127
93
|
# that means first variable that has been set
|
128
|
-
return
|
94
|
+
return ::CascadingConfiguration::Variable::ConfigurationSupport.get_configuration_searching_upward( self,
|
95
|
+
configuration_name )
|
129
96
|
|
130
97
|
end
|
131
98
|
end
|
@@ -140,17 +107,13 @@ module CascadingConfiguration::Setting::Interface::GettersSetters
|
|
140
107
|
|
141
108
|
configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
|
142
109
|
|
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 )
|
110
|
+
instance_configuration_support_module = ::CascadingConfiguration::Variable::ConfigurationSupport.instance_configuration_support_module( self )
|
111
|
+
local_instance_configuration_support_module = ::CascadingConfiguration::Variable::ConfigurationSupport.local_instance_configuration_support_module( self )
|
146
112
|
|
147
113
|
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
|
-
|
114
|
+
|
152
115
|
# configuration setter returns setting variable (variable from self), which is now the ID of value
|
153
|
-
return
|
116
|
+
return ::CascadingConfiguration::Variable::ConfigurationSupport.set_configuration_variable( self, configuration_name, value )
|
154
117
|
|
155
118
|
end
|
156
119
|
|
@@ -172,18 +135,14 @@ module CascadingConfiguration::Setting::Interface::GettersSetters
|
|
172
135
|
|
173
136
|
configuration_getter_name = configuration_name
|
174
137
|
|
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 )
|
138
|
+
instance_configuration_support_module = ::CascadingConfiguration::Variable::ConfigurationSupport.instance_configuration_support_module( self )
|
139
|
+
local_instance_configuration_support_module = ::CascadingConfiguration::Variable::ConfigurationSupport.local_instance_configuration_support_module( self )
|
178
140
|
|
179
141
|
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
142
|
|
184
143
|
# configuration getter returns current setting value (taken from first superclass with setting)
|
185
144
|
# that means first variable that has been set
|
186
|
-
return
|
145
|
+
return ::CascadingConfiguration::Variable::ConfigurationSupport.get_configuration_variable( self, configuration_name )
|
187
146
|
|
188
147
|
end
|
189
148
|
|
@@ -205,16 +164,13 @@ module CascadingConfiguration::Setting::Interface::GettersSetters
|
|
205
164
|
|
206
165
|
configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
|
207
166
|
|
208
|
-
instance_configuration_support_module = CascadingConfiguration::Variable.instance_configuration_support_module( self )
|
167
|
+
instance_configuration_support_module = ::CascadingConfiguration::Variable::ConfigurationSupport.instance_configuration_support_module( self )
|
209
168
|
|
210
169
|
instance_configuration_support_module.module_eval do
|
211
170
|
define_method( configuration_setter_name ) do |value|
|
212
171
|
|
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
172
|
# configuration setter returns setting variable (variable from self), which is now the ID of value
|
217
|
-
return
|
173
|
+
return ::CascadingConfiguration::Variable::ConfigurationSupport.set_configuration_variable( self, configuration_name, value )
|
218
174
|
|
219
175
|
end
|
220
176
|
end
|
@@ -229,17 +185,14 @@ module CascadingConfiguration::Setting::Interface::GettersSetters
|
|
229
185
|
|
230
186
|
configuration_getter_name = configuration_name
|
231
187
|
|
232
|
-
instance_configuration_support_module = CascadingConfiguration::Variable.instance_configuration_support_module( self )
|
188
|
+
instance_configuration_support_module = ::CascadingConfiguration::Variable::ConfigurationSupport.instance_configuration_support_module( self )
|
233
189
|
|
234
190
|
instance_configuration_support_module.module_eval do
|
235
191
|
define_method( configuration_getter_name ) do
|
236
192
|
|
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
193
|
# configuration getter returns current setting value (taken from first superclass with setting)
|
241
194
|
# that means first variable that has been set
|
242
|
-
return
|
195
|
+
return ::CascadingConfiguration::Variable::ConfigurationSupport.get_configuration_variable( self, configuration_name )
|
243
196
|
|
244
197
|
end
|
245
198
|
end
|
@@ -254,16 +207,13 @@ module CascadingConfiguration::Setting::Interface::GettersSetters
|
|
254
207
|
|
255
208
|
configuration_setter_name = ( configuration_name.to_s + '=' ).to_s
|
256
209
|
|
257
|
-
local_instance_configuration_support_module = CascadingConfiguration::Variable.local_instance_configuration_support_module( self )
|
210
|
+
local_instance_configuration_support_module = ::CascadingConfiguration::Variable::ConfigurationSupport.local_instance_configuration_support_module( self )
|
258
211
|
|
259
212
|
local_instance_configuration_support_module.module_eval do
|
260
213
|
define_method( configuration_setter_name ) do |value|
|
261
214
|
|
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
215
|
# configuration setter returns setting variable (variable from self), which is now the ID of value
|
266
|
-
return
|
216
|
+
return ::CascadingConfiguration::Variable::ConfigurationSupport.set_configuration_variable( self, configuration_name, value )
|
267
217
|
|
268
218
|
end
|
269
219
|
end
|
@@ -278,17 +228,14 @@ module CascadingConfiguration::Setting::Interface::GettersSetters
|
|
278
228
|
|
279
229
|
configuration_getter_name = configuration_name
|
280
230
|
|
281
|
-
local_instance_configuration_support_module = CascadingConfiguration::Variable.local_instance_configuration_support_module( self )
|
231
|
+
local_instance_configuration_support_module = ::CascadingConfiguration::Variable::ConfigurationSupport.local_instance_configuration_support_module( self )
|
282
232
|
|
283
233
|
local_instance_configuration_support_module.module_eval do
|
284
234
|
define_method( configuration_getter_name ) do
|
285
235
|
|
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
236
|
# configuration getter returns current setting value (taken from first superclass with setting)
|
290
237
|
# that means first variable that has been set
|
291
|
-
return
|
238
|
+
return ::CascadingConfiguration::Variable::ConfigurationSupport.get_configuration_variable( self, configuration_name )
|
292
239
|
|
293
240
|
end
|
294
241
|
end
|
@@ -171,7 +171,7 @@ describe CascadingConfiguration::Setting do
|
|
171
171
|
# extending a module or class works like a finalizer for the cascading configuration
|
172
172
|
# if the configuration is re-opened at a later point (including or extending a lower ancestor)
|
173
173
|
# then the configuration will still cascade upward
|
174
|
-
# this permits ancestors in the
|
174
|
+
# this permits ancestors in the hierarchy to skip out on configurations
|
175
175
|
# upward cascade can be frozen at any point using :freeze!, which will prevent further upward lookup
|
176
176
|
|
177
177
|
# possibilities:
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cascading-configuration-setting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.6.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Asher
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-02-02 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: module-cluster
|