cascading-configuration-hash 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +0 -40
- data/lib/cascading-configuration-hash/CascadingConfiguration/CompositingHash/Instance.rb +3 -10
- data/lib/cascading-configuration-hash/CascadingConfiguration/Hash/ModuleInclusionExtensionSupport.rb +8 -6
- data/lib/cascading-configuration-hash/CascadingConfiguration/Hash.rb +9 -45
- data/lib/cascading-configuration-hash.rb +2 -0
- metadata +3 -3
data/README.md
CHANGED
@@ -174,46 +174,6 @@ end
|
|
174
174
|
|
175
175
|
Cascading-configuration also provides several other convenience functions.
|
176
176
|
|
177
|
-
### Variable Name Prefixing ###
|
178
|
-
|
179
|
-
Configuration prefix can be set so that variables use property name with the configuration prefix prepended.
|
180
|
-
|
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.
|
182
|
-
|
183
|
-
```ruby
|
184
|
-
module SomeModule
|
185
|
-
|
186
|
-
include CascadingConfiguration
|
187
|
-
|
188
|
-
attr_configuration :some_setting
|
189
|
-
|
190
|
-
self.some_setting = :a_value
|
191
|
-
|
192
|
-
instance_variables.include?( :@some_setting ) # => true
|
193
|
-
|
194
|
-
# we can declare a prefix for specific properties
|
195
|
-
attr_configuration_prefix '__configuration_prefix__', :some_other_setting
|
196
|
-
|
197
|
-
attr_configuration :some_other_setting, :yet_another_setting
|
198
|
-
|
199
|
-
self.some_setting = :some_value
|
200
|
-
self.yet_another_setting = :another_value
|
201
|
-
|
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
|
205
|
-
|
206
|
-
# or we can declare a prefix for all properties defined after prefix is declared
|
207
|
-
attr_configuration_prefix '__another_configuration_prefix__'
|
208
|
-
|
209
|
-
attr_configuration :still_another_prefix
|
210
|
-
|
211
|
-
instance_variables.include?( :@still_another_prefix ) # => false
|
212
|
-
instance_variables.include?( :@__another_configuration_prefix__still_another_prefix ) # => true
|
213
|
-
|
214
|
-
end
|
215
|
-
```
|
216
|
-
|
217
177
|
### Method Redefinition ###
|
218
178
|
|
219
179
|
Any declared configuration is defined in order to support locally redefining the method and accessing the original by calling super.
|
@@ -1,18 +1,11 @@
|
|
1
1
|
|
2
2
|
module CascadingConfiguration::CompositingHash::Instance
|
3
3
|
|
4
|
-
|
4
|
+
extend ModuleCluster
|
5
5
|
|
6
|
-
|
7
|
-
# self.included #
|
8
|
-
###################
|
6
|
+
extend CascadingConfiguration::InternalModuleStub
|
9
7
|
|
10
|
-
|
11
|
-
module_self = self
|
12
|
-
class_or_module.instance_eval do
|
13
|
-
extend module_self
|
14
|
-
end
|
15
|
-
end
|
8
|
+
include_also_extends( self )
|
16
9
|
|
17
10
|
################################################
|
18
11
|
# composite_hash_for_cascading_configuration #
|
data/lib/cascading-configuration-hash/CascadingConfiguration/Hash/ModuleInclusionExtensionSupport.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
|
2
2
|
module CascadingConfiguration::Hash::ModuleInclusionExtensionSupport
|
3
3
|
|
4
|
-
|
4
|
+
extend ModuleCluster
|
5
|
+
|
6
|
+
extend CascadingConfiguration::InternalModuleStub
|
5
7
|
|
6
8
|
##############
|
7
9
|
# included #
|
@@ -9,15 +11,13 @@ module CascadingConfiguration::Hash::ModuleInclusionExtensionSupport
|
|
9
11
|
|
10
12
|
def included( class_or_module )
|
11
13
|
super if defined?( super )
|
12
|
-
# CascadingConfiguration::Hash
|
14
|
+
# the module that is including/extending CascadingConfiguration::Hash
|
13
15
|
module_self = self
|
14
16
|
class_or_module.instance_eval do
|
15
17
|
# include accessors defined for instances
|
16
18
|
include module_self.accessor_instance_support
|
17
19
|
# extend accessors defined for modules (and classes, which are modules)
|
18
|
-
extend
|
19
|
-
extend CascadingConfiguration::Hash
|
20
|
-
extend CascadingConfiguration::Hash::ModuleInclusionExtensionSupport unless is_a?( Class )
|
20
|
+
extend module_self.accessor_module_support
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -28,9 +28,11 @@ module CascadingConfiguration::Hash::ModuleInclusionExtensionSupport
|
|
28
28
|
def extended( class_or_module )
|
29
29
|
super if defined?( super )
|
30
30
|
# CascadingConfiguration::Hash
|
31
|
-
|
31
|
+
module_self = self
|
32
32
|
class_or_module.instance_eval do
|
33
|
+
# extend accessors defined for modules (and classes, which are modules)
|
33
34
|
extend module_self.accessor_module_support
|
35
|
+
# tell ancestor_configuration_chain to search the eigenclass chain as well
|
34
36
|
extend CascadingConfiguration::Variable::EigenclassConfigurationChain
|
35
37
|
end
|
36
38
|
end
|
@@ -1,56 +1,20 @@
|
|
1
1
|
|
2
2
|
module CascadingConfiguration::Hash
|
3
3
|
|
4
|
+
extend ModuleCluster
|
5
|
+
|
4
6
|
extend CascadingConfiguration::InternalModuleStub
|
5
7
|
|
6
8
|
include CascadingConfiguration::Variable
|
7
9
|
include CascadingConfiguration::CompositingHash::Instance
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
CascadingConfiguration::Variable.define_accessor_instance_support( class_or_module )
|
15
|
-
CascadingConfiguration::Variable.define_accessor_module_support( class_or_module )
|
16
|
-
super
|
17
|
-
end
|
18
|
-
|
19
|
-
########################
|
20
|
-
# self.extend_object #
|
21
|
-
########################
|
22
|
-
|
23
|
-
def self.extend_object( class_or_module )
|
24
|
-
CascadingConfiguration::Variable.define_accessor_module_support( class_or_module )
|
25
|
-
super
|
26
|
-
end
|
27
|
-
|
28
|
-
###################
|
29
|
-
# self.included #
|
30
|
-
###################
|
31
|
-
|
32
|
-
def self.included( class_or_module )
|
33
|
-
module_self = self
|
34
|
-
class_or_module.instance_eval do
|
35
|
-
extend module_self
|
36
|
-
extend module_self::Interface
|
37
|
-
extend module_self::AccessorDefinitionMethods
|
38
|
-
extend CascadingConfiguration::Variable::Interface
|
39
|
-
extend CascadingConfiguration::Hash::ModuleInclusionExtensionSupport unless is_a?( Class )
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
###################
|
44
|
-
# self.extended #
|
45
|
-
###################
|
11
|
+
include_cascades_extends( CascadingConfiguration::Hash,
|
12
|
+
CascadingConfiguration::Hash::Interface,
|
13
|
+
CascadingConfiguration::Hash::AccessorDefinitionMethods )
|
14
|
+
|
15
|
+
include_cascades_extends_to_module( CascadingConfiguration::Hash::ModuleInclusionExtensionSupport )
|
46
16
|
|
47
|
-
|
48
|
-
|
49
|
-
class_or_module.instance_eval do
|
50
|
-
extend module_self::Interface
|
51
|
-
extend module_self::AccessorDefinitionMethods
|
52
|
-
extend CascadingConfiguration::Variable::Interface
|
53
|
-
end
|
54
|
-
end
|
17
|
+
extend_cascades_extends( CascadingConfiguration::Hash::Interface,
|
18
|
+
CascadingConfiguration::Hash::AccessorDefinitionMethods )
|
55
19
|
|
56
20
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 1.2.
|
8
|
+
- 4
|
9
|
+
version: 1.2.4
|
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-
|
17
|
+
date: 2011-08-01 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|