cascading-configuration-hash 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,9 +23,8 @@ module CascadingConfiguration::CompositingHash::Instance
23
23
  composite_hash = nil
24
24
 
25
25
  klass = ( is_a?( Module ) ? self : self.class )
26
- accessor_support_module = klass::AccessorSupportModule
27
26
  self_instance = self
28
- accessor_support_module.instance_eval do
27
+ accessor_module_support.instance_eval do
29
28
  unless composite_hash = ( ( @composite_hashes ||= Hash.new )[ cascading_name ] ||= Hash.new )[ self_instance ]
30
29
  composite_hash = ::CascadingConfiguration::CompositingHash.new( cascading_name, self_instance )
31
30
  @composite_hashes[ cascading_name ][ self_instance ] = composite_hash
@@ -10,7 +10,7 @@ class CascadingConfiguration::CompositingHash < Hash
10
10
  def initialize( cascading_name, working_instance )
11
11
  @cascading_name = cascading_name
12
12
  @working_class = ( working_instance.is_a?( Module ) ? working_instance : working_instance.class )
13
- @cascading_variable = @working_class::AccessorSupportModule.cascading_variable_name( @cascading_name )
13
+ @cascading_variable = @working_class.accessor_module_support.cascading_variable_name( @cascading_name )
14
14
  @working_instance = working_instance
15
15
  # if first ancestor can have a composite array, register self with it in case it gets updated in the future
16
16
  if ( first_ancestor = @working_instance.first_ancestor ).respond_to?( :composite_hash_for_cascading_configuration )
@@ -0,0 +1,91 @@
1
+
2
+ module CascadingConfiguration::Hash::ConfigurationAccessors
3
+
4
+ extend CascadingConfiguration::InternalModuleStub
5
+
6
+ ##################################
7
+ # define_cascading_hash_setter #
8
+ ##################################
9
+
10
+ def define_cascading_hash_setter( configuration_name )
11
+ configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
12
+ [ accessor_instance_support, accessor_module_support ].compact.each do |accessor_support_module|
13
+ accessor_support_module.module_eval do
14
+ define_method( configuration_setter_name ) do |hash|
15
+ # we want the hash to supplant existing config
16
+ return composite_hash_for_cascading_configuration( configuration_name ).replace( hash )
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ ##################################
23
+ # define_cascading_hash_getter #
24
+ ##################################
25
+
26
+ def define_cascading_hash_getter( configuration_name )
27
+ configuration_getter_name = configuration_name
28
+ [ accessor_instance_support, accessor_module_support ].compact.each do |accessor_support_module|
29
+ accessor_support_module.module_eval do
30
+ define_method( configuration_getter_name ) do
31
+ return composite_hash_for_cascading_configuration( configuration_name )
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ ############################################
38
+ # define_class_configuration_hash_setter #
39
+ ############################################
40
+
41
+ def define_class_configuration_hash_setter( configuration_name )
42
+ configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
43
+ accessor_module_support.module_eval do
44
+ define_method( configuration_setter_name ) do |hash|
45
+ # we want the hash to supplant existing config
46
+ return composite_hash_for_cascading_configuration( configuration_name ).replace( hash )
47
+ end
48
+ end
49
+ end
50
+
51
+ ############################################
52
+ # define_class_configuration_hash_getter #
53
+ ############################################
54
+
55
+ def define_class_configuration_hash_getter( configuration_name )
56
+ configuration_getter_name = configuration_name
57
+ accessor_module_support.module_eval do
58
+ define_method( configuration_getter_name ) do
59
+ return composite_hash_for_cascading_configuration( configuration_name )
60
+ end
61
+ end
62
+ end
63
+
64
+ ############################################
65
+ # define_local_configuration_hash_setter #
66
+ ############################################
67
+
68
+ def define_local_configuration_hash_setter( configuration_name )
69
+ configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
70
+ accessor_instance_support.module_eval do
71
+ define_method( configuration_setter_name ) do |hash|
72
+ # we want the hash to supplant existing config
73
+ return composite_hash_for_cascading_configuration( configuration_name ).replace( hash )
74
+ end
75
+ end
76
+ end
77
+
78
+ ############################################
79
+ # define_local_configuration_hash_getter #
80
+ ############################################
81
+
82
+ def define_local_configuration_hash_getter( configuration_name )
83
+ configuration_getter_name = configuration_name
84
+ accessor_instance_support.module_eval do
85
+ define_method( configuration_getter_name ) do
86
+ return composite_hash_for_cascading_configuration( configuration_name )
87
+ end
88
+ end
89
+ end
90
+
91
+ end
@@ -0,0 +1,66 @@
1
+
2
+ module CascadingConfiguration::Hash::Interface
3
+
4
+ extend CascadingConfiguration::InternalModuleStub
5
+
6
+ #############################
7
+ # attr_configuration_hash #
8
+ #############################
9
+
10
+ # defines configuration in class or module
11
+ # configuration cascades downward to instance including all classes or modules in-between
12
+ def attr_configuration_hash( *property_names, & compositing_block )
13
+
14
+ property_names.each do |this_property_name|
15
+ accessor_module_support.set_compositing_proc( this_property_name, compositing_block ) if block_given?
16
+ # define configuration setter
17
+ define_cascading_hash_setter( this_property_name )
18
+ # define configuration getter
19
+ define_cascading_hash_getter( this_property_name )
20
+ end
21
+
22
+ return self
23
+
24
+ end
25
+
26
+ ###################################
27
+ # attr_class_configuration_hash #
28
+ ###################################
29
+
30
+ # defines configuration in class or module
31
+ # configuration cascades downward to last class or module
32
+ def attr_class_configuration_hash( *property_names, & compositing_block )
33
+
34
+ property_names.each do |this_property_name|
35
+ accessor_module_support.set_compositing_proc( this_property_name, compositing_block ) if block_given?
36
+ # define configuration setter
37
+ define_class_configuration_hash_setter( this_property_name )
38
+ # define configuration getter
39
+ define_class_configuration_hash_getter( this_property_name )
40
+ end
41
+
42
+ return self
43
+
44
+ end
45
+
46
+ ###################################
47
+ # attr_local_configuration_hash #
48
+ ###################################
49
+
50
+ # defines configuration in present class or module context
51
+ # configuration does not cascade
52
+ def attr_local_configuration_hash( *property_names, & compositing_block )
53
+
54
+ property_names.each do |this_property_name|
55
+ accessor_module_support.set_compositing_proc( this_property_name, compositing_block ) if block_given?
56
+ # define configuration setter
57
+ define_local_configuration_hash_setter( this_property_name )
58
+ # define configuration getter
59
+ define_local_configuration_hash_getter( this_property_name )
60
+ end
61
+
62
+ return self
63
+
64
+ end
65
+
66
+ end
@@ -0,0 +1,38 @@
1
+
2
+ module CascadingConfiguration::Hash::ModuleInclusionExtensionSupport
3
+
4
+ extend CascadingConfiguration::InternalModuleStub
5
+
6
+ ##############
7
+ # included #
8
+ ##############
9
+
10
+ def included( class_or_module )
11
+ super if defined?( super )
12
+ # CascadingConfiguration::Hash
13
+ module_self = self
14
+ class_or_module.instance_eval do
15
+ # include accessors defined for instances
16
+ include module_self.accessor_instance_support
17
+ # extend accessors defined for modules (and classes, which are modules)
18
+ extend module_self.accessor_module_support
19
+ extend CascadingConfiguration::Hash
20
+ extend CascadingConfiguration::Hash::ModuleInclusionExtensionSupport unless is_a?( Class )
21
+ end
22
+ end
23
+
24
+ ##############
25
+ # extended #
26
+ ##############
27
+
28
+ def extended( class_or_module )
29
+ super if defined?( super )
30
+ # CascadingConfiguration::Hash
31
+ module_self = self
32
+ class_or_module.instance_eval do
33
+ extend module_self.accessor_module_support
34
+ extend CascadingConfiguration::Variable::EigenclassConfigurationChain
35
+ end
36
+ end
37
+
38
+ end
@@ -6,6 +6,25 @@ module CascadingConfiguration::Hash
6
6
  include CascadingConfiguration::Variable
7
7
  include CascadingConfiguration::CompositingHash::Instance
8
8
 
9
+ ##########################
10
+ # self.append_features #
11
+ ##########################
12
+
13
+ def self.append_features( class_or_module )
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
+
9
28
  ###################
10
29
  # self.included #
11
30
  ###################
@@ -13,11 +32,22 @@ module CascadingConfiguration::Hash
13
32
  def self.included( class_or_module )
14
33
  module_self = self
15
34
  class_or_module.instance_eval do
16
- extend module_self
17
- extend module_self::Accessors
18
- extend module_self::ClassInstance
19
- # module support
20
- extend CascadingConfiguration::Hash::ModuleInstance unless is_a?( Class )
35
+ extend module_self
36
+ extend module_self::Interface
37
+ extend module_self::ConfigurationAccessors
38
+ extend CascadingConfiguration::Hash::ModuleInclusionExtensionSupport unless is_a?( Class )
39
+ end
40
+ end
41
+
42
+ ###################
43
+ # self.extended #
44
+ ###################
45
+
46
+ def self.extended( class_or_module )
47
+ module_self = self
48
+ class_or_module.instance_eval do
49
+ extend module_self::Interface
50
+ extend module_self::ConfigurationAccessors
21
51
  end
22
52
  end
23
53
 
@@ -39,7 +39,7 @@ class CascadingConfiguration::CompositingHash < Hash
39
39
  ###########################################
40
40
 
41
41
  def update_composite_self_for_parent_hash( parent_hash, second_hash )
42
- if compositing_proc = @working_class::AccessorSupportModule.get_compositing_proc( @cascading_name )
42
+ if compositing_proc = @working_class.accessor_module_support.get_compositing_proc( @cascading_name )
43
43
  # if we have a compositing proc defined, use its result to replace
44
44
  parent_hash_copy = Hash.new
45
45
  parent_hash_copy.merge!( parent_hash ) if parent_hash
@@ -13,13 +13,13 @@ module CascadingConfiguration
13
13
  class LocalConfigurationHash < Hash
14
14
  end
15
15
  module Hash
16
- module Accessors
16
+ module ConfigurationAccessors
17
17
  end
18
- module ClassInstance
18
+ module Interface
19
19
  end
20
20
  module ObjectInstance
21
21
  end
22
- module ModuleInstance
22
+ module ModuleInclusionExtensionSupport
23
23
  end
24
24
  end
25
25
  end
@@ -30,6 +30,6 @@ require_relative 'cascading-configuration-hash/CascadingConfiguration/Compositin
30
30
  require_relative 'cascading-configuration-hash/CascadingConfiguration/LocalConfigurationHash.rb'
31
31
  require_relative 'cascading-configuration-hash/CascadingConfiguration/_private_/LocalConfigurationHash.rb'
32
32
  require_relative 'cascading-configuration-hash/CascadingConfiguration/Hash.rb'
33
- require_relative 'cascading-configuration-hash/CascadingConfiguration/Hash/Accessors.rb'
34
- require_relative 'cascading-configuration-hash/CascadingConfiguration/Hash/ClassInstance.rb'
35
- require_relative 'cascading-configuration-hash/CascadingConfiguration/Hash/ModuleInstance.rb'
33
+ require_relative 'cascading-configuration-hash/CascadingConfiguration/Hash/ConfigurationAccessors.rb'
34
+ require_relative 'cascading-configuration-hash/CascadingConfiguration/Hash/Interface.rb'
35
+ require_relative 'cascading-configuration-hash/CascadingConfiguration/Hash/ModuleInclusionExtensionSupport.rb'
@@ -1,26 +1,26 @@
1
1
 
2
2
  require_relative '../../../lib/cascading-configuration-hash.rb'
3
3
 
4
- describe CascadingConfiguration::Hash::Accessors do
4
+ describe CascadingConfiguration::Hash::ConfigurationAccessors do
5
5
 
6
6
  ######################################
7
- # define_configuration_hash_setter #
8
- # define_configuration_hash_getter #
7
+ # define_cascading_hash_setter #
8
+ # define_cascading_hash_getter #
9
9
  ######################################
10
10
 
11
11
  it 'can define a method to get and modify the configuration hash' do
12
12
  class CascadingConfiguration::Hash::Mock
13
13
  include CascadingConfiguration::Variable
14
- extend CascadingConfiguration::Hash::Accessors
14
+ extend CascadingConfiguration::Hash::ConfigurationAccessors
15
15
  include CascadingConfiguration::Hash::ObjectInstance
16
- extend CascadingConfiguration::Hash::ClassInstance
16
+ extend CascadingConfiguration::Hash::Interface
17
17
  end
18
18
  # setter
19
- CascadingConfiguration::Hash::Mock.define_configuration_hash_setter( :some_configuration )
19
+ CascadingConfiguration::Hash::Mock.define_cascading_hash_setter( :some_configuration )
20
20
  CascadingConfiguration::Hash::Mock.methods.include?( :some_configuration= ).should == true
21
21
  CascadingConfiguration::Hash::Mock.instance_methods.include?( :some_configuration= ).should == true
22
22
  # getter
23
- CascadingConfiguration::Hash::Mock.define_configuration_hash_getter( :some_configuration )
23
+ CascadingConfiguration::Hash::Mock.define_cascading_hash_getter( :some_configuration )
24
24
  CascadingConfiguration::Hash::Mock.methods.include?( :some_configuration ).should == true
25
25
  CascadingConfiguration::Hash::Mock.instance_methods.include?( :some_configuration ).should == true
26
26
  end
@@ -8,30 +8,124 @@ describe CascadingConfiguration::Hash do
8
8
  #############################
9
9
 
10
10
  it 'can define a configuration hash, which is the primary interface' do
11
- module CascadingConfiguration::Hash::MockModule
12
- include CascadingConfiguration::Hash
11
+
12
+ # possibilities:
13
+ # * module extended with setting
14
+ # => singleton gets attr_configuration and configurations
15
+ # => including modules and classes get nothing
16
+ # => extending modules and classes get nothing
17
+ # => instances of including and extending classes get nothing
18
+ # * module included with setting
19
+ # => singleton gets attr_configuration and configurations
20
+ # => including modules and classes get attr_configuration and configurations
21
+ # => instances of including classes get configurations
22
+ # => extending modules and classes get attr_configuration and configurations
23
+ # => instances of extending classes get nothing
24
+ module CascadingConfiguration::Hash::MockModuleExtended
25
+ extend CascadingConfiguration::Hash
26
+ # => singleton gets attr_configuration and configurations
27
+ respond_to?( :attr_configuration_hash ).should == true
13
28
  attr_configuration_hash :configuration_setting
29
+ respond_to?( :configuration_setting ).should == true
14
30
  configuration_setting.should == {}
15
31
  self.configuration_setting[ :a_configuration ] = :some_value
16
32
  configuration_setting.should == { :a_configuration => :some_value }
33
+ instance_methods.include?( :configuration_setting ).should == false
34
+ # => including modules and classes get nothing
35
+ module SubmoduleIncluding
36
+ include CascadingConfiguration::Hash::MockModuleExtended
37
+ instance_methods.include?( :configuration_setting ).should == false
38
+ respond_to?( :configuration_setting ).should == false
39
+ end
40
+ # => extending modules and classes get nothing
41
+ module SubmoduleExtending
42
+ extend CascadingConfiguration::Hash::MockModuleExtended
43
+ instance_methods.include?( :configuration_setting ).should == false
44
+ respond_to?( :configuration_setting ).should == false
45
+ end
46
+ # => instances of including and extending classes get nothing
47
+ class ClassIncluding
48
+ include CascadingConfiguration::Hash::MockModuleExtended
49
+ instance_methods.include?( :configuration_setting ).should == false
50
+ respond_to?( :configuration_setting ).should == false
51
+ end
52
+ class ClassExtending
53
+ extend CascadingConfiguration::Hash::MockModuleExtended
54
+ instance_methods.include?( :configuration_setting ).should == false
55
+ respond_to?( :configuration_setting ).should == false
56
+ end
17
57
  end
18
58
 
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
59
+ # * module included with setting
60
+ module CascadingConfiguration::Hash::MockModuleIncluded
61
+ include CascadingConfiguration::Hash
62
+ # => singleton gets attr_configuration and configurations
63
+ respond_to?( :attr_configuration_hash ).should == true
64
+ attr_configuration_hash :configuration_setting
65
+ respond_to?( :configuration_setting ).should == true
66
+ configuration_setting.should == {}
67
+ self.configuration_setting[ :a_configuration ] = :some_value
26
68
  configuration_setting.should == { :a_configuration => :some_value }
69
+ instance_methods.include?( :configuration_setting ).should == true
70
+ # => including modules and classes get attr_configuration and configurations
71
+ module SubmoduleIncluding
72
+ include CascadingConfiguration::Hash::MockModuleIncluded
73
+ instance_methods.include?( :configuration_setting ).should == true
74
+ respond_to?( :configuration_setting ).should == true
75
+ configuration_setting.should == { :a_configuration => :some_value }
76
+ configuration_setting[ :other_setting ] = :some_value
77
+ configuration_setting.should == { :a_configuration => :some_value,
78
+ :other_setting => :some_value }
79
+ configuration_setting.delete( :other_setting ).should == :some_value
80
+ configuration_setting.should == { :a_configuration => :some_value }
81
+ end
82
+ # => extending modules and classes get attr_configuration and configurations
83
+ module SubmoduleExtending
84
+ extend CascadingConfiguration::Hash::MockModuleIncluded
85
+ # if we're extended then we want to use the eigenclass ancestor chain
86
+ # - the first ancestor will be the extending module
87
+ # - the rest of the ancestors will be the extending module's include chain
88
+ respond_to?( :configuration_setting ).should == true
89
+ configuration_setting.should == { :a_configuration => :some_value }
90
+ configuration_setting[ :other_setting ] = :some_value
91
+ configuration_setting.should == { :a_configuration => :some_value,
92
+ :other_setting => :some_value }
93
+ configuration_setting.delete( :other_setting ).should == :some_value
94
+ configuration_setting.should == { :a_configuration => :some_value }
95
+ instance_methods.include?( :configuration_setting ).should == false
96
+ end
97
+ # => instances of including classes get configurations
98
+ class ClassIncluding
99
+ include CascadingConfiguration::Hash::MockModuleIncluded
100
+ instance_methods.include?( :configuration_setting ).should == true
101
+ respond_to?( :configuration_setting ).should == true
102
+ configuration_setting.should == { :a_configuration => :some_value }
103
+ configuration_setting[ :other_setting ] = :some_value
104
+ configuration_setting.should == { :a_configuration => :some_value,
105
+ :other_setting => :some_value }
106
+ configuration_setting.delete( :other_setting ).should == :some_value
107
+ configuration_setting.should == { :a_configuration => :some_value }
108
+ end
109
+ setting_class_including_instance = ClassIncluding.new
110
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == true
111
+ setting_class_including_instance.configuration_setting.should == { :a_configuration => :some_value }
112
+ setting_class_including_instance.configuration_setting.delete( :a_configuration )
113
+ class ClassExtending
114
+ extend CascadingConfiguration::Hash::MockModuleIncluded
115
+ respond_to?( :configuration_setting ).should == true
116
+ configuration_setting.should == { :a_configuration => :some_value }
117
+ configuration_setting[ :other_setting ] = :some_value
118
+ configuration_setting.should == { :a_configuration => :some_value,
119
+ :other_setting => :some_value }
120
+ configuration_setting.delete( :other_setting ).should == :some_value
121
+ configuration_setting.should == { :a_configuration => :some_value }
122
+ end
123
+ setting_class_including_instance = ClassExtending.new
124
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == false
27
125
  end
28
126
 
29
- module CascadingConfiguration::Hash::MockModule3
30
- include CascadingConfiguration::Hash::MockModule2
31
- end
32
-
33
127
  class CascadingConfiguration::Hash::MockClass
34
- include CascadingConfiguration::Hash::MockModule3
128
+ include CascadingConfiguration::Hash::MockModuleIncluded::SubmoduleIncluding
35
129
  configuration_setting.should == { :a_configuration => :some_value }
36
130
  configuration_setting[ :other_setting ] = :some_value
37
131
  configuration_setting.should == { :a_configuration => :some_value,
@@ -53,9 +147,6 @@ describe CascadingConfiguration::Hash do
53
147
  :another_configuration => :some_value }
54
148
  end
55
149
 
56
- CascadingConfiguration::Hash::MockClassSub1.new.configuration_setting.should == { :a_configuration => :some_value,
57
- :another_configuration => :some_value }
58
-
59
150
  object_instance_two = CascadingConfiguration::Hash::MockClassSub1.new
60
151
  object_instance_two.configuration_setting.should == { :a_configuration => :some_value,
61
152
  :another_configuration => :some_value }
@@ -104,6 +195,7 @@ describe CascadingConfiguration::Hash do
104
195
  :some_other_configuration => :some_value }
105
196
 
106
197
  module CascadingConfiguration::Hash::MockModule
198
+ include CascadingConfiguration::Hash
107
199
  attr_configuration_hash :some_hash do |parent_hash, composite_hash|
108
200
  parent_hash.each do |this_key, this_data|
109
201
  if existing_value = composite_hash[ this_key ]
@@ -119,25 +211,11 @@ describe CascadingConfiguration::Hash do
119
211
  end
120
212
 
121
213
  module CascadingConfiguration::Hash::MockModule2
214
+ include CascadingConfiguration::Hash::MockModule
122
215
  self.some_hash.should == { :one => 1, :two => 2 }
123
216
  self.some_hash.replace( { :one => 1, :two => 2 } )
124
217
  self.some_hash.should == { :one => 0, :two => 0 }
125
218
  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
219
 
142
220
  end
143
221
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 5
9
- version: 1.1.5
8
+ - 6
9
+ version: 1.1.6
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-18 00:00:00 -04:00
17
+ date: 2011-07-19 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -43,16 +43,16 @@ files:
43
43
  - lib/cascading-configuration-hash/CascadingConfiguration/_private_/LocalConfigurationHash.rb
44
44
  - lib/cascading-configuration-hash/CascadingConfiguration/CompositingHash/Instance.rb
45
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
46
+ - lib/cascading-configuration-hash/CascadingConfiguration/Hash/ConfigurationAccessors.rb
47
+ - lib/cascading-configuration-hash/CascadingConfiguration/Hash/Interface.rb
48
+ - lib/cascading-configuration-hash/CascadingConfiguration/Hash/ModuleInclusionExtensionSupport.rb
49
49
  - lib/cascading-configuration-hash/CascadingConfiguration/Hash.rb
50
50
  - lib/cascading-configuration-hash/CascadingConfiguration/LocalConfigurationHash.rb
51
51
  - lib/cascading-configuration-hash.rb
52
52
  - spec/CascadingConfiguration/CascadingCompositeHash_spec.rb
53
- - spec/CascadingConfiguration/ConfigurationHash_spec.rb
54
- - spec/CascadingConfiguration/Hash/Accessors_spec.rb
53
+ - spec/CascadingConfiguration/Hash/ConfigurationAccessors_spec.rb
55
54
  - spec/CascadingConfiguration/Hash_spec.rb
55
+ - spec/CascadingConfiguration/LocalConfigurationHash_spec.rb
56
56
  - README.md
57
57
  - README.rdoc
58
58
  has_rdoc: true
@@ -1,33 +0,0 @@
1
-
2
- module CascadingConfiguration::Hash::Accessors
3
-
4
- extend CascadingConfiguration::InternalModuleStub
5
-
6
- ######################################
7
- # define_configuration_hash_setter #
8
- ######################################
9
-
10
- def define_configuration_hash_setter( configuration_name )
11
- configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
12
- self::AccessorSupportModule.module_eval do
13
- define_method( configuration_setter_name ) do |hash|
14
- # we want the hash to supplant existing config
15
- return composite_hash_for_cascading_configuration( configuration_name ).replace( hash )
16
- end
17
- end
18
- end
19
-
20
- ######################################
21
- # define_configuration_hash_getter #
22
- ######################################
23
-
24
- def define_configuration_hash_getter( configuration_name )
25
- configuration_getter_name = configuration_name
26
- self::AccessorSupportModule.module_eval do
27
- define_method( configuration_getter_name ) do
28
- return composite_hash_for_cascading_configuration( configuration_name )
29
- end
30
- end
31
- end
32
-
33
- end
@@ -1,24 +0,0 @@
1
-
2
- module CascadingConfiguration::Hash::ClassInstance
3
-
4
- extend CascadingConfiguration::InternalModuleStub
5
-
6
- #############################
7
- # attr_configuration_hash #
8
- #############################
9
-
10
- def attr_configuration_hash( *property_names, & compositing_block )
11
-
12
- property_names.each do |this_property_name|
13
- self::AccessorSupportModule.set_compositing_proc( this_property_name, compositing_block ) if block_given?
14
- # define configuration setter
15
- define_configuration_hash_setter( this_property_name )
16
- # define configuration getter
17
- define_configuration_hash_getter( this_property_name )
18
- end
19
-
20
- return self
21
-
22
- end
23
-
24
- end
@@ -1,34 +0,0 @@
1
-
2
- module CascadingConfiguration::Hash::ModuleInstance
3
-
4
- extend CascadingConfiguration::InternalModuleStub
5
-
6
- ##############
7
- # included #
8
- ##############
9
-
10
- def included( class_or_module )
11
- super if method_defined?( :super )
12
- # CascadingConfiguration::Hash
13
- module_self = self
14
- class_or_module.instance_eval do
15
- # cascade CascadingConfiguration::Hash
16
- include CascadingConfiguration::Hash
17
- end
18
- end
19
-
20
- ##############
21
- # extended #
22
- ##############
23
-
24
- def extended( class_or_module )
25
- super if method_defined?( :super )
26
- # CascadingConfiguration::Hash
27
- module_self = self
28
- class_or_module.instance_eval do
29
- # cascade CascadingConfiguration::Hash
30
- include CascadingConfiguration::Hash
31
- end
32
- end
33
-
34
- end