cascading-configuration-hash 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +308 -29
- data/README.rdoc +1 -27
- data/lib/cascading-configuration-hash/CascadingConfiguration/CompositingHash/Instance.rb +39 -0
- data/lib/cascading-configuration-hash/CascadingConfiguration/CompositingHash.rb +136 -0
- data/lib/cascading-configuration-hash/CascadingConfiguration/Hash/Accessors.rb +33 -0
- data/lib/cascading-configuration-hash/CascadingConfiguration/Hash/ClassInstance.rb +24 -0
- data/lib/cascading-configuration-hash/CascadingConfiguration/Hash/ModuleInstance.rb +34 -0
- data/lib/cascading-configuration-hash/CascadingConfiguration/Hash.rb +24 -0
- data/lib/cascading-configuration-hash/CascadingConfiguration/LocalConfigurationHash.rb +83 -0
- data/lib/cascading-configuration-hash/CascadingConfiguration/_private_/CompositingHash.rb +79 -0
- data/lib/cascading-configuration-hash/CascadingConfiguration/_private_/LocalConfigurationHash.rb +31 -0
- data/lib/cascading-configuration-hash.rb +35 -0
- data/spec/CascadingConfiguration/CascadingCompositeHash_spec.rb +402 -0
- data/spec/CascadingConfiguration/ConfigurationHash_spec.rb +95 -0
- data/spec/CascadingConfiguration/Hash/Accessors_spec.rb +28 -0
- data/spec/CascadingConfiguration/Hash_spec.rb +144 -0
- metadata +16 -5
- data/lib/cascading-configuration/CascadingConfiguration.rb +0 -16
- data/lib/cascading-configuration.rb +0 -15
- data/spec/CascadingConfiguration_spec.rb +0 -224
@@ -0,0 +1,95 @@
|
|
1
|
+
|
2
|
+
require_relative '../../lib/cascading-configuration-hash.rb'
|
3
|
+
|
4
|
+
describe CascadingConfiguration::LocalConfigurationHash do
|
5
|
+
|
6
|
+
#########
|
7
|
+
# []= #
|
8
|
+
#########
|
9
|
+
|
10
|
+
it 'can add elements' do
|
11
|
+
hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
|
12
|
+
hash_instance[ :some_setting ] = :some_value
|
13
|
+
hash_instance.should == { :some_setting => :some_value }
|
14
|
+
hash_instance.exclude_array.include?( :some_setting ).should == false
|
15
|
+
hash_instance[ :other_setting ] = :some_value
|
16
|
+
hash_instance.should == { :some_setting => :some_value,
|
17
|
+
:other_setting => :some_value }
|
18
|
+
hash_instance.exclude_array.include?( :other_setting ).should == false
|
19
|
+
end
|
20
|
+
|
21
|
+
###########
|
22
|
+
# store #
|
23
|
+
###########
|
24
|
+
|
25
|
+
it 'can add elements' do
|
26
|
+
hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
|
27
|
+
hash_instance.store( :some_setting, :some_value )
|
28
|
+
hash_instance.should == { :some_setting => :some_value }
|
29
|
+
hash_instance.exclude_array.include?( :some_setting ).should == false
|
30
|
+
hash_instance.store( :other_setting, :some_value )
|
31
|
+
hash_instance.should == { :some_setting => :some_value,
|
32
|
+
:other_setting => :some_value }
|
33
|
+
hash_instance.exclude_array.include?( :other_setting ).should == false
|
34
|
+
end
|
35
|
+
|
36
|
+
############
|
37
|
+
# delete #
|
38
|
+
############
|
39
|
+
|
40
|
+
it 'can exclude elements' do
|
41
|
+
hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
|
42
|
+
hash_instance[ :some_setting ] = :some_value
|
43
|
+
hash_instance.delete( :some_setting ).should == :some_value
|
44
|
+
hash_instance.should == {}
|
45
|
+
hash_instance.exclude_array.include?( :some_setting ).should == true
|
46
|
+
end
|
47
|
+
|
48
|
+
############
|
49
|
+
# merge! #
|
50
|
+
############
|
51
|
+
|
52
|
+
it 'can merge from another hash' do
|
53
|
+
hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
|
54
|
+
hash_instance.merge!( { :some_setting => :some_value } )
|
55
|
+
hash_instance.should == { :some_setting => :some_value }
|
56
|
+
end
|
57
|
+
|
58
|
+
#############
|
59
|
+
# replace #
|
60
|
+
#############
|
61
|
+
|
62
|
+
it 'can replace existing elements with others' do
|
63
|
+
hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
|
64
|
+
hash_instance.merge!( { :some_setting => :some_value } )
|
65
|
+
hash_instance.should == { :some_setting => :some_value }
|
66
|
+
hash_instance.replace( { :other_setting => :some_value } )
|
67
|
+
hash_instance.should == { :other_setting => :some_value }
|
68
|
+
hash_instance.exclude_array.include?( :other_setting ).should == false
|
69
|
+
hash_instance.exclude_array.include?( :some_setting ).should == true
|
70
|
+
end
|
71
|
+
|
72
|
+
###########
|
73
|
+
# shift #
|
74
|
+
###########
|
75
|
+
|
76
|
+
it 'can shift the first element' do
|
77
|
+
hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
|
78
|
+
hash_instance.merge!( { :some_setting => :some_value } )
|
79
|
+
hash_instance.shift.should == [ :some_setting, :some_value ]
|
80
|
+
hash_instance.should == {}
|
81
|
+
end
|
82
|
+
|
83
|
+
###########
|
84
|
+
# clear #
|
85
|
+
###########
|
86
|
+
|
87
|
+
it 'can clear, causing present elements to be excluded' do
|
88
|
+
hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
|
89
|
+
hash_instance.merge!( { :some_setting => :some_value } )
|
90
|
+
hash_instance.clear
|
91
|
+
hash_instance.should == {}
|
92
|
+
hash_instance.exclude_array.include?( :some_setting ).should == true
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
require_relative '../../../lib/cascading-configuration-hash.rb'
|
3
|
+
|
4
|
+
describe CascadingConfiguration::Hash::Accessors do
|
5
|
+
|
6
|
+
######################################
|
7
|
+
# define_configuration_hash_setter #
|
8
|
+
# define_configuration_hash_getter #
|
9
|
+
######################################
|
10
|
+
|
11
|
+
it 'can define a method to get and modify the configuration hash' do
|
12
|
+
class CascadingConfiguration::Hash::Mock
|
13
|
+
include CascadingConfiguration::Variable
|
14
|
+
extend CascadingConfiguration::Hash::Accessors
|
15
|
+
include CascadingConfiguration::Hash::ObjectInstance
|
16
|
+
extend CascadingConfiguration::Hash::ClassInstance
|
17
|
+
end
|
18
|
+
# setter
|
19
|
+
CascadingConfiguration::Hash::Mock.define_configuration_hash_setter( :some_configuration )
|
20
|
+
CascadingConfiguration::Hash::Mock.methods.include?( :some_configuration= ).should == true
|
21
|
+
CascadingConfiguration::Hash::Mock.instance_methods.include?( :some_configuration= ).should == true
|
22
|
+
# getter
|
23
|
+
CascadingConfiguration::Hash::Mock.define_configuration_hash_getter( :some_configuration )
|
24
|
+
CascadingConfiguration::Hash::Mock.methods.include?( :some_configuration ).should == true
|
25
|
+
CascadingConfiguration::Hash::Mock.instance_methods.include?( :some_configuration ).should == true
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
|
2
|
+
require_relative '../../lib/cascading-configuration-hash.rb'
|
3
|
+
|
4
|
+
describe CascadingConfiguration::Hash do
|
5
|
+
|
6
|
+
#############################
|
7
|
+
# attr_configuration_hash #
|
8
|
+
#############################
|
9
|
+
|
10
|
+
it 'can define a configuration hash, which is the primary interface' do
|
11
|
+
module CascadingConfiguration::Hash::MockModule
|
12
|
+
include CascadingConfiguration::Hash
|
13
|
+
attr_configuration_hash :configuration_setting
|
14
|
+
configuration_setting.should == {}
|
15
|
+
self.configuration_setting[ :a_configuration ] = :some_value
|
16
|
+
configuration_setting.should == { :a_configuration => :some_value }
|
17
|
+
end
|
18
|
+
|
19
|
+
module CascadingConfiguration::Hash::MockModule2
|
20
|
+
include CascadingConfiguration::Hash::MockModule
|
21
|
+
configuration_setting.should == { :a_configuration => :some_value }
|
22
|
+
configuration_setting[ :other_setting ] = :some_value
|
23
|
+
configuration_setting.should == { :a_configuration => :some_value,
|
24
|
+
:other_setting => :some_value }
|
25
|
+
configuration_setting.delete( :other_setting ).should == :some_value
|
26
|
+
configuration_setting.should == { :a_configuration => :some_value }
|
27
|
+
end
|
28
|
+
|
29
|
+
module CascadingConfiguration::Hash::MockModule3
|
30
|
+
include CascadingConfiguration::Hash::MockModule2
|
31
|
+
end
|
32
|
+
|
33
|
+
class CascadingConfiguration::Hash::MockClass
|
34
|
+
include CascadingConfiguration::Hash::MockModule3
|
35
|
+
configuration_setting.should == { :a_configuration => :some_value }
|
36
|
+
configuration_setting[ :other_setting ] = :some_value
|
37
|
+
configuration_setting.should == { :a_configuration => :some_value,
|
38
|
+
:other_setting => :some_value }
|
39
|
+
configuration_setting.delete( :other_setting ).should == :some_value
|
40
|
+
configuration_setting.should == { :a_configuration => :some_value }
|
41
|
+
end
|
42
|
+
|
43
|
+
object_instance_one = CascadingConfiguration::Hash::MockClass.new
|
44
|
+
object_instance_one.configuration_setting.should == { :a_configuration => :some_value }
|
45
|
+
object_instance_one.configuration_setting[ :some_other_configuration ] = :some_value
|
46
|
+
object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
|
47
|
+
:some_other_configuration => :some_value }
|
48
|
+
|
49
|
+
class CascadingConfiguration::Hash::MockClassSub1 < CascadingConfiguration::Hash::MockClass
|
50
|
+
configuration_setting.should == { :a_configuration => :some_value }
|
51
|
+
self.configuration_setting[ :another_configuration ] = :some_value
|
52
|
+
configuration_setting.should == { :a_configuration => :some_value,
|
53
|
+
:another_configuration => :some_value }
|
54
|
+
end
|
55
|
+
|
56
|
+
CascadingConfiguration::Hash::MockClassSub1.new.configuration_setting.should == { :a_configuration => :some_value,
|
57
|
+
:another_configuration => :some_value }
|
58
|
+
|
59
|
+
object_instance_two = CascadingConfiguration::Hash::MockClassSub1.new
|
60
|
+
object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
|
61
|
+
:another_configuration => :some_value }
|
62
|
+
object_instance_two.configuration_setting[ :some_other_configuration ] = :some_value
|
63
|
+
object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
|
64
|
+
:another_configuration => :some_value,
|
65
|
+
:some_other_configuration => :some_value }
|
66
|
+
|
67
|
+
# change ancestor setting
|
68
|
+
CascadingConfiguration::Hash::MockClass.configuration_setting[ :a_yet_unused_configuration ] = :some_value
|
69
|
+
CascadingConfiguration::Hash::MockClass.configuration_setting.should == { :a_configuration => :some_value,
|
70
|
+
:a_yet_unused_configuration => :some_value }
|
71
|
+
object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
|
72
|
+
:a_yet_unused_configuration => :some_value,
|
73
|
+
:some_other_configuration => :some_value }
|
74
|
+
CascadingConfiguration::Hash::MockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
|
75
|
+
:a_yet_unused_configuration => :some_value,
|
76
|
+
:another_configuration => :some_value }
|
77
|
+
object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
|
78
|
+
:a_yet_unused_configuration => :some_value,
|
79
|
+
:another_configuration => :some_value,
|
80
|
+
:some_other_configuration => :some_value }
|
81
|
+
|
82
|
+
# freeze ancestor setting
|
83
|
+
object_instance_one.configuration_setting.freeze!
|
84
|
+
object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
|
85
|
+
:a_yet_unused_configuration => :some_value,
|
86
|
+
:some_other_configuration => :some_value }
|
87
|
+
CascadingConfiguration::Hash::MockClassSub1.configuration_setting.freeze!
|
88
|
+
CascadingConfiguration::Hash::MockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
|
89
|
+
:a_yet_unused_configuration => :some_value,
|
90
|
+
:another_configuration => :some_value }
|
91
|
+
CascadingConfiguration::Hash::MockClass.configuration_setting[ :non_cascading_configuration ] = :some_value
|
92
|
+
CascadingConfiguration::Hash::MockClass.configuration_setting.should == { :a_configuration => :some_value,
|
93
|
+
:a_yet_unused_configuration => :some_value,
|
94
|
+
:non_cascading_configuration => :some_value }
|
95
|
+
object_instance_one.configuration_setting.should == { :a_configuration => :some_value,
|
96
|
+
:a_yet_unused_configuration => :some_value,
|
97
|
+
:some_other_configuration => :some_value }
|
98
|
+
CascadingConfiguration::Hash::MockClassSub1.configuration_setting.should == { :a_configuration => :some_value,
|
99
|
+
:a_yet_unused_configuration => :some_value,
|
100
|
+
:another_configuration => :some_value }
|
101
|
+
object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
|
102
|
+
:a_yet_unused_configuration => :some_value,
|
103
|
+
:another_configuration => :some_value,
|
104
|
+
:some_other_configuration => :some_value }
|
105
|
+
|
106
|
+
module CascadingConfiguration::Hash::MockModule
|
107
|
+
attr_configuration_hash :some_hash do |parent_hash, composite_hash|
|
108
|
+
parent_hash.each do |this_key, this_data|
|
109
|
+
if existing_value = composite_hash[ this_key ]
|
110
|
+
composite_hash[ this_key ] = this_data - existing_value
|
111
|
+
else
|
112
|
+
composite_hash[ this_key ] = this_data
|
113
|
+
end
|
114
|
+
end
|
115
|
+
composite_hash
|
116
|
+
end
|
117
|
+
self.some_hash = { :one => 1, :two => 2 }
|
118
|
+
self.some_hash.should == { :one => 1, :two => 2 }
|
119
|
+
end
|
120
|
+
|
121
|
+
module CascadingConfiguration::Hash::MockModule2
|
122
|
+
self.some_hash.should == { :one => 1, :two => 2 }
|
123
|
+
self.some_hash.replace( { :one => 1, :two => 2 } )
|
124
|
+
self.some_hash.should == { :one => 0, :two => 0 }
|
125
|
+
end
|
126
|
+
|
127
|
+
# test two
|
128
|
+
|
129
|
+
module CascadingConfiguration::Hash::MockModuleExtended
|
130
|
+
include CascadingConfiguration::Hash
|
131
|
+
attr_configuration_hash :configuration_setting
|
132
|
+
configuration_setting.should == {}
|
133
|
+
configuration_setting[ :a_configuration ] = :some_value
|
134
|
+
configuration_setting.should == { :a_configuration => :some_value }
|
135
|
+
end
|
136
|
+
|
137
|
+
class CascadingConfiguration::Hash::MockClassExtended
|
138
|
+
extend CascadingConfiguration::Hash::MockModuleExtended
|
139
|
+
configuration_setting.should == { :a_configuration => :some_value }
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 5
|
9
|
+
version: 1.1.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Asher
|
@@ -39,9 +39,20 @@ extensions: []
|
|
39
39
|
extra_rdoc_files: []
|
40
40
|
|
41
41
|
files:
|
42
|
-
- lib/cascading-configuration/CascadingConfiguration.rb
|
43
|
-
- lib/cascading-configuration.rb
|
44
|
-
-
|
42
|
+
- lib/cascading-configuration-hash/CascadingConfiguration/_private_/CompositingHash.rb
|
43
|
+
- lib/cascading-configuration-hash/CascadingConfiguration/_private_/LocalConfigurationHash.rb
|
44
|
+
- lib/cascading-configuration-hash/CascadingConfiguration/CompositingHash/Instance.rb
|
45
|
+
- lib/cascading-configuration-hash/CascadingConfiguration/CompositingHash.rb
|
46
|
+
- lib/cascading-configuration-hash/CascadingConfiguration/Hash/Accessors.rb
|
47
|
+
- lib/cascading-configuration-hash/CascadingConfiguration/Hash/ClassInstance.rb
|
48
|
+
- lib/cascading-configuration-hash/CascadingConfiguration/Hash/ModuleInstance.rb
|
49
|
+
- lib/cascading-configuration-hash/CascadingConfiguration/Hash.rb
|
50
|
+
- lib/cascading-configuration-hash/CascadingConfiguration/LocalConfigurationHash.rb
|
51
|
+
- lib/cascading-configuration-hash.rb
|
52
|
+
- spec/CascadingConfiguration/CascadingCompositeHash_spec.rb
|
53
|
+
- spec/CascadingConfiguration/ConfigurationHash_spec.rb
|
54
|
+
- spec/CascadingConfiguration/Hash/Accessors_spec.rb
|
55
|
+
- spec/CascadingConfiguration/Hash_spec.rb
|
45
56
|
- README.md
|
46
57
|
- README.rdoc
|
47
58
|
has_rdoc: true
|
@@ -1,16 +0,0 @@
|
|
1
|
-
|
2
|
-
module CascadingConfiguration
|
3
|
-
|
4
|
-
###################
|
5
|
-
# self.included #
|
6
|
-
###################
|
7
|
-
|
8
|
-
def self.included( class_or_module )
|
9
|
-
class_or_module.instance_eval do
|
10
|
-
include CascadingConfiguration::Setting
|
11
|
-
include CascadingConfiguration::Array
|
12
|
-
include CascadingConfiguration::Hash
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
|
2
|
-
if $cascading_configuration_development
|
3
|
-
require_relative '../setting/lib/cascading-configuration-setting.rb'
|
4
|
-
require_relative '../settings-array/lib/cascading-configuration-array.rb'
|
5
|
-
require_relative '../settings-hash/lib/cascading-configuration-hash.rb'
|
6
|
-
else
|
7
|
-
require 'cascading-configuration-setting'
|
8
|
-
require 'cascading-configuration-array'
|
9
|
-
require 'cascading-configuration-hash'
|
10
|
-
end
|
11
|
-
|
12
|
-
module CascadingConfiguration
|
13
|
-
end
|
14
|
-
|
15
|
-
require_relative 'cascading-configuration/CascadingConfiguration.rb'
|
@@ -1,224 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative '../lib/cascading-configuration.rb'
|
3
|
-
|
4
|
-
describe CascadingConfiguration do
|
5
|
-
|
6
|
-
########################
|
7
|
-
# attr_configuration #
|
8
|
-
########################
|
9
|
-
|
10
|
-
it 'can declare an attribute as a cascading configuration setting' do
|
11
|
-
module CascadingConfiguration::MockModule2
|
12
|
-
end
|
13
|
-
|
14
|
-
# first module
|
15
|
-
module CascadingConfiguration::MockModule
|
16
|
-
include CascadingConfiguration
|
17
|
-
attr_configuration :some_configuration
|
18
|
-
self.some_configuration = :some_value
|
19
|
-
some_configuration.should == :some_value
|
20
|
-
end
|
21
|
-
|
22
|
-
# including module 1
|
23
|
-
module CascadingConfiguration::MockModule2
|
24
|
-
include CascadingConfiguration::MockModule
|
25
|
-
some_configuration.should == :some_value
|
26
|
-
self.some_configuration = :module_value
|
27
|
-
some_configuration.should == :module_value
|
28
|
-
end
|
29
|
-
|
30
|
-
# including module 2
|
31
|
-
module CascadingConfiguration::MockModule3
|
32
|
-
include CascadingConfiguration::MockModule2
|
33
|
-
end
|
34
|
-
|
35
|
-
# top class
|
36
|
-
class CascadingConfiguration::MockClass
|
37
|
-
include CascadingConfiguration::MockModule3
|
38
|
-
some_configuration.should == :module_value
|
39
|
-
self.some_configuration = :another_value
|
40
|
-
some_configuration.should == :another_value
|
41
|
-
end
|
42
|
-
|
43
|
-
# instance of top class
|
44
|
-
object_instance_one = CascadingConfiguration::MockClass.new
|
45
|
-
object_instance_one.some_configuration.should == :another_value
|
46
|
-
object_instance_one.some_configuration = :yet_another_value
|
47
|
-
object_instance_one.some_configuration.should == :yet_another_value
|
48
|
-
CascadingConfiguration::MockClass.some_configuration.should == :another_value
|
49
|
-
CascadingConfiguration::MockModule.some_configuration.should == :some_value
|
50
|
-
|
51
|
-
# first inheriting class
|
52
|
-
class CascadingConfiguration::MockClassSub1 < CascadingConfiguration::MockClass
|
53
|
-
some_configuration.should == :another_value
|
54
|
-
self.some_configuration = :a_value_not_yet_used
|
55
|
-
some_configuration.should == :a_value_not_yet_used
|
56
|
-
CascadingConfiguration::MockClass.some_configuration.should == :another_value
|
57
|
-
CascadingConfiguration::MockModule.some_configuration.should == :some_value
|
58
|
-
end
|
59
|
-
|
60
|
-
# Instance of First Inheriting Class
|
61
|
-
object_instance_two = CascadingConfiguration::MockClassSub1.new
|
62
|
-
object_instance_two.some_configuration.should == :a_value_not_yet_used
|
63
|
-
object_instance_one.some_configuration.should == :yet_another_value
|
64
|
-
CascadingConfiguration::MockClass.some_configuration.should == :another_value
|
65
|
-
CascadingConfiguration::MockModule.some_configuration.should == :some_value
|
66
|
-
|
67
|
-
# Second Inheriting Class
|
68
|
-
class CascadingConfiguration::MockClassSub2 < CascadingConfiguration::MockClassSub1
|
69
|
-
some_configuration.should == :a_value_not_yet_used
|
70
|
-
self.some_configuration = :another_value_not_yet_used
|
71
|
-
some_configuration.should == :another_value_not_yet_used
|
72
|
-
end
|
73
|
-
|
74
|
-
# Instance of Second Inheriting Class
|
75
|
-
object_instance_three = CascadingConfiguration::MockClassSub2.new
|
76
|
-
object_instance_three.some_configuration.should == :another_value_not_yet_used
|
77
|
-
object_instance_three.some_configuration = :one_more_unused_value
|
78
|
-
object_instance_three.some_configuration.should == :one_more_unused_value
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
##############################
|
83
|
-
# attr_configuration_array #
|
84
|
-
##############################
|
85
|
-
|
86
|
-
it 'can declare an attribute as a cascading configuration array' do
|
87
|
-
|
88
|
-
# first module
|
89
|
-
module CascadingConfiguration::MockModule
|
90
|
-
attr_configuration_array :some_array_configuration
|
91
|
-
self.some_array_configuration = [ :some_value ]
|
92
|
-
some_array_configuration.should == [ :some_value ]
|
93
|
-
end
|
94
|
-
|
95
|
-
# including module 1
|
96
|
-
module CascadingConfiguration::MockModule2
|
97
|
-
some_array_configuration.should == [ :some_value ]
|
98
|
-
self.some_array_configuration = [ :module_value ]
|
99
|
-
some_array_configuration.should == [ :module_value ]
|
100
|
-
end
|
101
|
-
|
102
|
-
# including module 2
|
103
|
-
module CascadingConfiguration::MockModule3
|
104
|
-
some_array_configuration.should == [ :module_value ]
|
105
|
-
end
|
106
|
-
|
107
|
-
# top class
|
108
|
-
class CascadingConfiguration::MockClass
|
109
|
-
some_array_configuration.should == [ :module_value ]
|
110
|
-
self.some_array_configuration = [ :another_value ]
|
111
|
-
some_array_configuration.should == [ :another_value ]
|
112
|
-
end
|
113
|
-
|
114
|
-
# instance of top class
|
115
|
-
object_instance_one = CascadingConfiguration::MockClass.new
|
116
|
-
object_instance_one.some_array_configuration.should == [ :another_value ]
|
117
|
-
object_instance_one.some_array_configuration = [ :yet_another_value ]
|
118
|
-
object_instance_one.some_array_configuration.should == [ :yet_another_value ]
|
119
|
-
CascadingConfiguration::MockClass.some_array_configuration.should == [ :another_value ]
|
120
|
-
CascadingConfiguration::MockModule.some_array_configuration.should == [ :some_value ]
|
121
|
-
|
122
|
-
# first inheriting class
|
123
|
-
class CascadingConfiguration::MockClassSub1 < CascadingConfiguration::MockClass
|
124
|
-
some_array_configuration.should == [ :another_value ]
|
125
|
-
self.some_array_configuration = [ :a_value_not_yet_used ]
|
126
|
-
some_array_configuration.should == [ :a_value_not_yet_used ]
|
127
|
-
CascadingConfiguration::MockClass.some_array_configuration.should == [ :another_value ]
|
128
|
-
CascadingConfiguration::MockModule.some_array_configuration.should == [ :some_value ]
|
129
|
-
end
|
130
|
-
|
131
|
-
# Instance of First Inheriting Class
|
132
|
-
object_instance_two = CascadingConfiguration::MockClassSub1.new
|
133
|
-
object_instance_two.some_array_configuration.should == [ :a_value_not_yet_used ]
|
134
|
-
object_instance_one.some_array_configuration.should == [ :yet_another_value ]
|
135
|
-
CascadingConfiguration::MockClass.some_array_configuration.should == [ :another_value ]
|
136
|
-
CascadingConfiguration::MockModule.some_array_configuration.should == [ :some_value ]
|
137
|
-
|
138
|
-
# Second Inheriting Class
|
139
|
-
class CascadingConfiguration::MockClassSub2 < CascadingConfiguration::MockClassSub1
|
140
|
-
some_array_configuration.should == [ :a_value_not_yet_used ]
|
141
|
-
self.some_array_configuration = [ :another_value_not_yet_used ]
|
142
|
-
some_array_configuration.should == [ :another_value_not_yet_used ]
|
143
|
-
end
|
144
|
-
|
145
|
-
# Instance of Second Inheriting Class
|
146
|
-
object_instance_three = CascadingConfiguration::MockClassSub2.new
|
147
|
-
object_instance_three.some_array_configuration.should == [ :another_value_not_yet_used ]
|
148
|
-
object_instance_three.some_array_configuration = [ :one_more_unused_value ]
|
149
|
-
object_instance_three.some_array_configuration.should == [ :one_more_unused_value ]
|
150
|
-
|
151
|
-
end
|
152
|
-
|
153
|
-
#############################
|
154
|
-
# attr_configuration_hash #
|
155
|
-
#############################
|
156
|
-
|
157
|
-
it 'can declare an attribute as a cascading configuration hash' do
|
158
|
-
|
159
|
-
# first module
|
160
|
-
module CascadingConfiguration::MockModule
|
161
|
-
attr_configuration_hash :some_hash_configuration
|
162
|
-
self.some_hash_configuration = { :some_value => :some_value }
|
163
|
-
some_hash_configuration.should == { :some_value => :some_value }
|
164
|
-
end
|
165
|
-
|
166
|
-
# including module 1
|
167
|
-
module CascadingConfiguration::MockModule2
|
168
|
-
some_hash_configuration.should == { :some_value => :some_value }
|
169
|
-
self.some_hash_configuration = { :module_value => :some_value }
|
170
|
-
some_hash_configuration.should == { :module_value => :some_value }
|
171
|
-
end
|
172
|
-
|
173
|
-
# including module 2
|
174
|
-
module CascadingConfiguration::MockModule3
|
175
|
-
|
176
|
-
end
|
177
|
-
|
178
|
-
# top class
|
179
|
-
class CascadingConfiguration::MockClass
|
180
|
-
some_hash_configuration.should == { :module_value => :some_value }
|
181
|
-
self.some_hash_configuration = { :another_value => :some_value }
|
182
|
-
some_hash_configuration.should == { :another_value => :some_value }
|
183
|
-
end
|
184
|
-
|
185
|
-
# instance of top class
|
186
|
-
object_instance_one = CascadingConfiguration::MockClass.new
|
187
|
-
object_instance_one.some_hash_configuration.should == { :another_value => :some_value }
|
188
|
-
object_instance_one.some_hash_configuration = { :yet_another_value => :some_value }
|
189
|
-
object_instance_one.some_hash_configuration.should == { :yet_another_value => :some_value }
|
190
|
-
CascadingConfiguration::MockClass.some_hash_configuration.should == { :another_value => :some_value }
|
191
|
-
CascadingConfiguration::MockModule.some_hash_configuration.should == { :some_value => :some_value }
|
192
|
-
|
193
|
-
# first inheriting class
|
194
|
-
class CascadingConfiguration::MockClassSub1 < CascadingConfiguration::MockClass
|
195
|
-
some_hash_configuration.should == { :another_value => :some_value }
|
196
|
-
self.some_hash_configuration = { :a_value_not_yet_used => :some_value }
|
197
|
-
some_hash_configuration.should == { :a_value_not_yet_used => :some_value }
|
198
|
-
CascadingConfiguration::MockClass.some_hash_configuration.should == { :another_value => :some_value }
|
199
|
-
CascadingConfiguration::MockModule.some_hash_configuration.should == { :some_value => :some_value }
|
200
|
-
end
|
201
|
-
|
202
|
-
# Instance of First Inheriting Class
|
203
|
-
object_instance_two = CascadingConfiguration::MockClassSub1.new
|
204
|
-
object_instance_two.some_hash_configuration.should == { :a_value_not_yet_used => :some_value }
|
205
|
-
object_instance_one.some_hash_configuration.should == { :yet_another_value => :some_value }
|
206
|
-
CascadingConfiguration::MockClass.some_hash_configuration.should == { :another_value => :some_value }
|
207
|
-
CascadingConfiguration::MockModule.some_hash_configuration.should == { :some_value => :some_value }
|
208
|
-
|
209
|
-
# Second Inheriting Class
|
210
|
-
class CascadingConfiguration::MockClassSub2 < CascadingConfiguration::MockClassSub1
|
211
|
-
some_hash_configuration.should == { :a_value_not_yet_used => :some_value }
|
212
|
-
self.some_hash_configuration = { :another_value_not_yet_used => :some_value }
|
213
|
-
some_hash_configuration.should == { :another_value_not_yet_used => :some_value }
|
214
|
-
end
|
215
|
-
|
216
|
-
# Instance of Second Inheriting Class
|
217
|
-
object_instance_three = CascadingConfiguration::MockClassSub2.new
|
218
|
-
object_instance_three.some_hash_configuration.should == { :another_value_not_yet_used => :some_value }
|
219
|
-
object_instance_three.some_hash_configuration = { :one_more_unused_value => :some_value }
|
220
|
-
object_instance_three.some_hash_configuration.should == { :one_more_unused_value => :some_value }
|
221
|
-
|
222
|
-
end
|
223
|
-
|
224
|
-
end
|