cascading_configuration 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +40 -0
- data/README.md +211 -0
- data/lib/cascading_configuration/array/sorted/unique.rb +110 -0
- data/lib/cascading_configuration/array/sorted.rb +106 -0
- data/lib/cascading_configuration/array/unique.rb +106 -0
- data/lib/cascading_configuration/array.rb +103 -0
- data/lib/cascading_configuration/core/enable_instance_support.rb +22 -0
- data/lib/cascading_configuration/core/enable_module_support.rb +24 -0
- data/lib/cascading_configuration/core/encapsulation.rb +343 -0
- data/lib/cascading_configuration/core/instance_controller/extension_module.rb +38 -0
- data/lib/cascading_configuration/core/instance_controller/support_module/instance_support_module.rb +21 -0
- data/lib/cascading_configuration/core/instance_controller/support_module/singleton_support_module.rb +21 -0
- data/lib/cascading_configuration/core/instance_controller/support_module.rb +253 -0
- data/lib/cascading_configuration/core/instance_controller.rb +840 -0
- data/lib/cascading_configuration/core/module/block_configurations/cascading_variables.rb +129 -0
- data/lib/cascading_configuration/core/module/block_configurations.rb +15 -0
- data/lib/cascading_configuration/core/module/extended_configurations/compositing_objects.rb +173 -0
- data/lib/cascading_configuration/core/module/extended_configurations.rb +65 -0
- data/lib/cascading_configuration/core/module/inheriting_values.rb +64 -0
- data/lib/cascading_configuration/core/module.rb +284 -0
- data/lib/cascading_configuration/core.rb +23 -0
- data/lib/cascading_configuration/hash.rb +103 -0
- data/lib/cascading_configuration/setting.rb +87 -0
- data/lib/cascading_configuration.rb +47 -0
- data/lib/namespaces.rb +9 -0
- data/lib/requires.rb +46 -0
- data/spec/cascading_configuration/array/sorted/unique_spec.rb +742 -0
- data/spec/cascading_configuration/array/sorted_spec.rb +741 -0
- data/spec/cascading_configuration/array/unique_spec.rb +746 -0
- data/spec/cascading_configuration/array_spec.rb +768 -0
- data/spec/cascading_configuration/core/encapsulation_spec.rb +208 -0
- data/spec/cascading_configuration/core/instance_controller/extension_module_spec.rb +26 -0
- data/spec/cascading_configuration/core/instance_controller/support_module_spec.rb +269 -0
- data/spec/cascading_configuration/core/instance_controller_spec.rb +273 -0
- data/spec/cascading_configuration/core/module/block_configurations/cascading_variables_spec.rb +17 -0
- data/spec/cascading_configuration/core/module/extended_configurations/compositing_objects_spec.rb +127 -0
- data/spec/cascading_configuration/core/module/extended_configurations_spec.rb +37 -0
- data/spec/cascading_configuration/core/module/inheriting_values_spec.rb +87 -0
- data/spec/cascading_configuration/core/module_spec.rb +491 -0
- data/spec/cascading_configuration/hash_spec.rb +826 -0
- data/spec/cascading_configuration/setting_spec.rb +687 -0
- data/spec/cascading_configuration_spec.rb +58 -0
- metadata +185 -0
data/CHANGELOG.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
## 6/18/2012 ##
|
3
|
+
|
4
|
+
Moved cascading_configuration-ancestors to a new independent gem: parallel-ancestry.
|
5
|
+
|
6
|
+
Now with Less Magic™ and more Tasty Sandwiches™!
|
7
|
+
|
8
|
+
Condensed cascading_configuration-variable, cascading_configuration-methods, cascading_configuration-definition, cascading_configuration-inheritance, cascading_configuration-module, cascading_configuration-setting, cascading_configuration-array, cascading_configuration-array-unique, cascading_configuration-array-sorted, cascading_configuration-sorted-unique, cascading_configuration-hash into a single gem with core support.
|
9
|
+
|
10
|
+
Adding new modules is now incredibly easy, and all the old spaghetti internal code is gone.
|
11
|
+
|
12
|
+
## 6/19/2012 ##
|
13
|
+
|
14
|
+
Fix for multiple arguments.
|
15
|
+
|
16
|
+
README updates.
|
17
|
+
|
18
|
+
Removed Methods module and submodules - methods moved into InstanceController directly.
|
19
|
+
|
20
|
+
Fixed parameters for alias methods on InstanceController.
|
21
|
+
|
22
|
+
Changed inheritance for extends to behave like module inheritance. Now extending an instance with a CCM-enabled module will cause instance methods to be appended to extended instances eigenclass chain; singleton methods will not cascade for extend.
|
23
|
+
|
24
|
+
Fixed Class instance configuration lookups.
|
25
|
+
|
26
|
+
Fixed for FalseClass.
|
27
|
+
|
28
|
+
Fixed for Object.
|
29
|
+
|
30
|
+
## 6/24/2012 ##
|
31
|
+
|
32
|
+
Added Instance and Singleton support module subclasses - fixes case where singleton support is created after extending with an instance with singleton support, causing the extending instance's singleton support to be both improperly included and below the instance, stomping any of its methods.
|
33
|
+
|
34
|
+
Added :initialize_configuration to CascadingConfiguration::Core::Module; subclasses override to perform object initialization post-creation. This is so that objects are initialized only after all objects have been instantiated.
|
35
|
+
|
36
|
+
## 6/27/2012 ##
|
37
|
+
|
38
|
+
Renamed project from cascading-configuration to cascading_configuration to match Rubygems guidelines for gem naming.
|
39
|
+
Ensured configurations don't re-register parents that are higher in the ancestor chain than the ones already registered.
|
40
|
+
|
data/README.md
ADDED
@@ -0,0 +1,211 @@
|
|
1
|
+
# Cascading Configuration #
|
2
|
+
|
3
|
+
http://rubygems.org/gems/cascading_configuration
|
4
|
+
|
5
|
+
# Summary #
|
6
|
+
|
7
|
+
Provides inheritable values across Ruby inheritance hierarchy or across arbitrary declared inheritance relations.
|
8
|
+
|
9
|
+
# Description #
|
10
|
+
|
11
|
+
Inheritable Objects and Downward-Compositing Hashes and Arrays; Downward-Transforming Values coming soon.
|
12
|
+
|
13
|
+
# Install #
|
14
|
+
|
15
|
+
* sudo gem install cascading_configuration
|
16
|
+
|
17
|
+
# Usage #
|
18
|
+
|
19
|
+
Since CascadingConfiguration produces configurations for both singletons and instances, include or extend of a CascadingConfiguration module (for instance CascadingConfiguration::Setting) also causes the including instance to be extended by module::ClassInstance (ie CascadingConfiguration::Setting::ClassInstance).
|
20
|
+
|
21
|
+
The result is that extending will enable only the singleton, whereas including will enable both singleton and instances.
|
22
|
+
|
23
|
+
Each module supports the same pattern for naming methods it provides.
|
24
|
+
|
25
|
+
The module has a name, which is used in each of the method types:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
:setting # => :attr_setting
|
29
|
+
:hash # => :attr_hash
|
30
|
+
:array # => :attr_array
|
31
|
+
:unique_array # => :attr_unique_array
|
32
|
+
:sorted_array # => :attr_sorted_array
|
33
|
+
:sorted_unique_array # => :attr_sorted_unique_array
|
34
|
+
```
|
35
|
+
|
36
|
+
For backwards compatibility, these methods are also available:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
:attr_configuration
|
40
|
+
:attr_configuration_hash
|
41
|
+
:attr_configuration_array
|
42
|
+
:attr_configuration_unique_array
|
43
|
+
:attr_configuration_sorted_array
|
44
|
+
:attr_configuration_sorted_unique_array
|
45
|
+
```
|
46
|
+
|
47
|
+
## Base Method Naming Pattern ##
|
48
|
+
|
49
|
+
There are 5 types of base methods:
|
50
|
+
|
51
|
+
### :attr\_[module\_name] ###
|
52
|
+
|
53
|
+
Cascading methods, which will affect instances according to include/extend pattern used.
|
54
|
+
|
55
|
+
### :attr\_module\_[module\_name] and attr\_class\_[module\_name] ###
|
56
|
+
|
57
|
+
Cascading module/class methods, which will affect all module singletons according to include/extend pattern used.
|
58
|
+
|
59
|
+
### :attr\_instance\_[module\_name] ###
|
60
|
+
|
61
|
+
Cascading instance methods, which will affect instances of including modules according to include/extend pattern used.
|
62
|
+
|
63
|
+
### :attr\_local\_[module\_name] ###
|
64
|
+
|
65
|
+
Non-cascading methods that will affect the instance declared on as well as instances of that instance, if applicable.
|
66
|
+
|
67
|
+
### :attr\_object\_[module\_name] ###
|
68
|
+
|
69
|
+
Non-cascading methods that will affect only the instance declared on.
|
70
|
+
|
71
|
+
## Inheritable Objects ##
|
72
|
+
|
73
|
+
Inheritable Objects are values received from an ancestor:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
module ModuleA
|
77
|
+
include CascadingConfiguration::Setting
|
78
|
+
attr_setting :some_setting
|
79
|
+
self.some_setting = :some_value
|
80
|
+
end
|
81
|
+
|
82
|
+
class ClassA
|
83
|
+
include ModuleA
|
84
|
+
self.some_setting = :some_other_value
|
85
|
+
end
|
86
|
+
|
87
|
+
class ClassB < ClassA
|
88
|
+
some_setting == :some_other_value
|
89
|
+
self.some_setting = :another_value
|
90
|
+
end
|
91
|
+
|
92
|
+
class ClassC < ClassB
|
93
|
+
some_setting == :another_value
|
94
|
+
end
|
95
|
+
```
|
96
|
+
|
97
|
+
Simply put, the instance asked for the value will look up its ancestor chain until it finds an explicitly assigned value, which it returns.
|
98
|
+
|
99
|
+
This is provided by:
|
100
|
+
|
101
|
+
* CascadingConfiguration::Setting
|
102
|
+
|
103
|
+
## Downward-Compositing Hashes and Arrays ##
|
104
|
+
|
105
|
+
Whether Hashes or Arrays, the idea is the same. We call the Compositing Objects. They all work the same way (automatically):
|
106
|
+
|
107
|
+
1. The compositing object is initialized with a reference to the configuration instance it is attached to.
|
108
|
+
2. The compositing object is initialized (separately) for its immediate parent object.
|
109
|
+
3. Whenever an update occurs, the compositing object updates its registered child object with the update.
|
110
|
+
|
111
|
+
This way the lower objects are kept in sync with parent elements. Overriding hooked methods (provided by HookedArray from the hooked-array gem) provides a great deal of flexible functionality, permitting elements to be transformed as they are passed down the ancestor hierarchy.
|
112
|
+
|
113
|
+
Right now there are 5 types of Compositing Objects:
|
114
|
+
|
115
|
+
* CascadingConfiguration::Hash
|
116
|
+
* CascadingConfiguration::Array
|
117
|
+
* CascadingConfiguration::Array::Unique
|
118
|
+
* CascadingConfiguration::Array::Sorted
|
119
|
+
* CascadingConfiguration::Array::Sorted::Unique
|
120
|
+
|
121
|
+
All work the same with the exception of differing compositing object types. All declarations of compositing object configurations also accept extension modules and/or a block that will be used to create an extension module. Extension modules will be used to extend the compositing object; extension modules automatically cascade along the ancestor hierarchy for a given configuration.
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
module ModuleA
|
125
|
+
include CascadingConfiguration::Array
|
126
|
+
attr_array :some_array
|
127
|
+
some_array == [ ]
|
128
|
+
some_array.push( :some_value )
|
129
|
+
some_array == [ :some_value ]
|
130
|
+
end
|
131
|
+
|
132
|
+
class ClassA
|
133
|
+
include ModuleA
|
134
|
+
some_array == [ :some_value ]
|
135
|
+
end
|
136
|
+
|
137
|
+
class ClassB < ClassA
|
138
|
+
some_array == [ :some_value ]
|
139
|
+
some_array.push( :another_value )
|
140
|
+
some_array == [ :some_value, :another_value ]
|
141
|
+
end
|
142
|
+
|
143
|
+
class ClassC < ClassB
|
144
|
+
some_setting == :another_value
|
145
|
+
some_array.delete( :some_value )
|
146
|
+
some_array == [ :another_value ]
|
147
|
+
end
|
148
|
+
```
|
149
|
+
|
150
|
+
The end result:
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
ModuleA.some_array == [ :some_value ]
|
154
|
+
|
155
|
+
ClassA.some_array == [ :some_value ]
|
156
|
+
|
157
|
+
ClassB.some_array == [ :some_value, :another_value ]
|
158
|
+
|
159
|
+
ClassA.some_array == [ :another_value ]
|
160
|
+
```
|
161
|
+
|
162
|
+
## Downward-Transforming Values ##
|
163
|
+
|
164
|
+
Downward-Transforming Values are not yet 100% implemented, but the remainder is minimal and will be coming soon.
|
165
|
+
|
166
|
+
Each time a child is registered, Downward-Transforming Values are processed via a block to produce the new value that the inheriting instance will receive.
|
167
|
+
|
168
|
+
Final details still being determined.
|
169
|
+
|
170
|
+
|
171
|
+
## Configuration Modules ##
|
172
|
+
|
173
|
+
Including or extending CascadingConfiguration includes or extends all of its configuration modules:
|
174
|
+
|
175
|
+
* CascadingConfiguration::Setting
|
176
|
+
* CascadingConfiguration::Hash
|
177
|
+
* CascadingConfiguration::Array
|
178
|
+
* CascadingConfiguration::Array::Unique
|
179
|
+
* CascadingConfiguration::Array::Sorted
|
180
|
+
* CascadingConfiguration::Array::Sorted::Unique
|
181
|
+
|
182
|
+
These modules can also be used individually in the same way (simply include or extend).
|
183
|
+
|
184
|
+
# Check Out the Code #
|
185
|
+
|
186
|
+
CascadingConfiguration is, in my opinion, a strong showing of what one can do with Ruby. Of particular interest is its demonstrated use of the parallel-ancestry gem. More very real world examples coming soon.
|
187
|
+
|
188
|
+
# License #
|
189
|
+
|
190
|
+
(The MIT License)
|
191
|
+
|
192
|
+
Copyright (c) Asher
|
193
|
+
|
194
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
195
|
+
a copy of this software and associated documentation files (the
|
196
|
+
'Software'), to deal in the Software without restriction, including
|
197
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
198
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
199
|
+
permit persons to whom the Software is furnished to do so, subject to
|
200
|
+
the following conditions:
|
201
|
+
|
202
|
+
The above copyright notice and this permission notice shall be
|
203
|
+
included in all copies or substantial portions of the Software.
|
204
|
+
|
205
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
206
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
207
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
208
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
209
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
210
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
211
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,110 @@
|
|
1
|
+
|
2
|
+
###
|
3
|
+
# CascadingConfiguration::Array::Sorted::Unique allows definition of array attributes that will composite downward
|
4
|
+
# through the ancestor chain and ensure that member elements remain sorted and unique.
|
5
|
+
#
|
6
|
+
module ::CascadingConfiguration::Array::Sorted::Unique
|
7
|
+
|
8
|
+
###
|
9
|
+
# Cascading array attribute methods, which will affect instances according to include/extend pattern used.
|
10
|
+
#
|
11
|
+
# @method attr_sorted_unique_array
|
12
|
+
#
|
13
|
+
# @overload attr_sorted_unique_array( *names )
|
14
|
+
#
|
15
|
+
# @scope
|
16
|
+
#
|
17
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String},Module] name The name to be used
|
18
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
19
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
20
|
+
#
|
21
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
22
|
+
# and runs module_eval( & block ) on instance with provided block.
|
23
|
+
#
|
24
|
+
# @return self
|
25
|
+
#
|
26
|
+
|
27
|
+
###
|
28
|
+
# Cascading array attribute module/class methods, which will affect all module singletons
|
29
|
+
# according to include/extend pattern used.
|
30
|
+
#
|
31
|
+
# @method attr_module_sorted_unique_array
|
32
|
+
#
|
33
|
+
# @overload attr_module_sorted_unique_array( *names )
|
34
|
+
#
|
35
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
36
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
37
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
38
|
+
#
|
39
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
40
|
+
# and runs module_eval( & block ) on instance with provided block.
|
41
|
+
#
|
42
|
+
# @return self
|
43
|
+
#
|
44
|
+
|
45
|
+
###
|
46
|
+
# Cascading array instance methods, which will affect instances of including modules according to
|
47
|
+
# include/extend pattern used.
|
48
|
+
#
|
49
|
+
# @method attr_instance_sorted_unique_array
|
50
|
+
#
|
51
|
+
# @overload attr_instance_sorted_unique_array( *names )
|
52
|
+
#
|
53
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
54
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
55
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
56
|
+
#
|
57
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
58
|
+
# and runs module_eval( & block ) on instance with provided block.
|
59
|
+
#
|
60
|
+
# @return self
|
61
|
+
#
|
62
|
+
|
63
|
+
###
|
64
|
+
# Non-cascading array methods that will affect the instance declared on as well as instances of that instance,
|
65
|
+
# if applicable.
|
66
|
+
#
|
67
|
+
# @method attr_local_sorted_unique_array
|
68
|
+
#
|
69
|
+
# @overload attr_local_sorted_unique_array( *names )
|
70
|
+
#
|
71
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
72
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
73
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
74
|
+
#
|
75
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
76
|
+
# and runs module_eval( & block ) on instance with provided block.
|
77
|
+
#
|
78
|
+
# @return self
|
79
|
+
#
|
80
|
+
|
81
|
+
###
|
82
|
+
# Non-cascading array methods that will affect only the instance declared on.
|
83
|
+
#
|
84
|
+
# @method attr_object_sorted_unique_array
|
85
|
+
#
|
86
|
+
# @overload attr_object_sorted_unique_array( *names )
|
87
|
+
#
|
88
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
89
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
90
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
91
|
+
#
|
92
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
93
|
+
# and runs module_eval( & block ) on instance with provided block.
|
94
|
+
#
|
95
|
+
# @return self
|
96
|
+
#
|
97
|
+
|
98
|
+
sorted_unique_array_module = ::CascadingConfiguration::Core::Module::ExtendedConfigurations::
|
99
|
+
CompositingObjects.new( :sorted_unique_array,
|
100
|
+
::CompositingArray::Sorted::Unique,
|
101
|
+
:default,
|
102
|
+
:unique_sorted_array,
|
103
|
+
:configuration_sorted_unique_array,
|
104
|
+
:configuration_unique_sorted_array )
|
105
|
+
|
106
|
+
::CascadingConfiguration::Core.enable( self, sorted_unique_array_module )
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
::CascadingConfiguration::Array::Unique::Sorted = ::CascadingConfiguration::Array::Sorted::Unique
|
@@ -0,0 +1,106 @@
|
|
1
|
+
|
2
|
+
###
|
3
|
+
# CascadingConfiguration::Array::Sorted allows definition of array attributes that will composite downward through
|
4
|
+
# the ancestor chain and ensure that member elements remain sorted.
|
5
|
+
#
|
6
|
+
module ::CascadingConfiguration::Array::Sorted
|
7
|
+
|
8
|
+
###
|
9
|
+
# Cascading array attribute methods, which will affect instances according to include/extend pattern used.
|
10
|
+
#
|
11
|
+
# @method attr_sorted_array
|
12
|
+
#
|
13
|
+
# @overload attr_sorted_array( *names )
|
14
|
+
#
|
15
|
+
# @scope
|
16
|
+
#
|
17
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String},Module] name The name to be used
|
18
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
19
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
20
|
+
#
|
21
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
22
|
+
# and runs module_eval( & block ) on instance with provided block.
|
23
|
+
#
|
24
|
+
# @return self
|
25
|
+
#
|
26
|
+
|
27
|
+
###
|
28
|
+
# Cascading array attribute module/class methods, which will affect all module singletons
|
29
|
+
# according to include/extend pattern used.
|
30
|
+
#
|
31
|
+
# @method attr_module_sorted_array
|
32
|
+
#
|
33
|
+
# @overload attr_module_sorted_array( *names )
|
34
|
+
#
|
35
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
36
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
37
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
38
|
+
#
|
39
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
40
|
+
# and runs module_eval( & block ) on instance with provided block.
|
41
|
+
#
|
42
|
+
# @return self
|
43
|
+
#
|
44
|
+
|
45
|
+
###
|
46
|
+
# Cascading array instance methods, which will affect instances of including modules according to
|
47
|
+
# include/extend pattern used.
|
48
|
+
#
|
49
|
+
# @method attr_instance_sorted_array
|
50
|
+
#
|
51
|
+
# @overload attr_instance_sorted_array( *names )
|
52
|
+
#
|
53
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
54
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
55
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
56
|
+
#
|
57
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
58
|
+
# and runs module_eval( & block ) on instance with provided block.
|
59
|
+
#
|
60
|
+
# @return self
|
61
|
+
#
|
62
|
+
|
63
|
+
###
|
64
|
+
# Non-cascading array methods that will affect the instance declared on as well as instances of that instance,
|
65
|
+
# if applicable.
|
66
|
+
#
|
67
|
+
# @method attr_local_sorted_array
|
68
|
+
#
|
69
|
+
# @overload attr_local_sorted_array( *names )
|
70
|
+
#
|
71
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
72
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
73
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
74
|
+
#
|
75
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
76
|
+
# and runs module_eval( & block ) on instance with provided block.
|
77
|
+
#
|
78
|
+
# @return self
|
79
|
+
#
|
80
|
+
|
81
|
+
###
|
82
|
+
# Non-cascading array methods that will affect only the instance declared on.
|
83
|
+
#
|
84
|
+
# @method attr_object_sorted_array
|
85
|
+
#
|
86
|
+
# @overload attr_object_sorted_array( *names )
|
87
|
+
#
|
88
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
89
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
90
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
91
|
+
#
|
92
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
93
|
+
# and runs module_eval( & block ) on instance with provided block.
|
94
|
+
#
|
95
|
+
# @return self
|
96
|
+
#
|
97
|
+
|
98
|
+
sorted_array_module = ::CascadingConfiguration::Core::Module::ExtendedConfigurations::
|
99
|
+
CompositingObjects.new( :sorted_array,
|
100
|
+
::CompositingArray::Sorted,
|
101
|
+
:default,
|
102
|
+
:configuration_sorted_array )
|
103
|
+
|
104
|
+
::CascadingConfiguration::Core.enable( self, sorted_array_module )
|
105
|
+
|
106
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
|
2
|
+
###
|
3
|
+
# CascadingConfiguration::Array allows definition of array attributes that will composite downward through
|
4
|
+
# the ancestor chain and ensure that member elements remain unique.
|
5
|
+
#
|
6
|
+
module ::CascadingConfiguration::Array::Unique
|
7
|
+
|
8
|
+
###
|
9
|
+
# Cascading array attribute methods, which will affect instances according to include/extend pattern used.
|
10
|
+
#
|
11
|
+
# @method attr_unique_array
|
12
|
+
#
|
13
|
+
# @overload attr_unique_array( *names )
|
14
|
+
#
|
15
|
+
# @scope
|
16
|
+
#
|
17
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String},Module] name The name to be used
|
18
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
19
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
20
|
+
#
|
21
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
22
|
+
# and runs module_eval( & block ) on instance with provided block.
|
23
|
+
#
|
24
|
+
# @return self
|
25
|
+
#
|
26
|
+
|
27
|
+
###
|
28
|
+
# Cascading array attribute module/class methods, which will affect all module singletons
|
29
|
+
# according to include/extend pattern used.
|
30
|
+
#
|
31
|
+
# @method attr_module_unique_array
|
32
|
+
#
|
33
|
+
# @overload attr_module_unique_array( *names )
|
34
|
+
#
|
35
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
36
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
37
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
38
|
+
#
|
39
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
40
|
+
# and runs module_eval( & block ) on instance with provided block.
|
41
|
+
#
|
42
|
+
# @return self
|
43
|
+
#
|
44
|
+
|
45
|
+
###
|
46
|
+
# Cascading array instance methods, which will affect instances of including modules according to
|
47
|
+
# include/extend pattern used.
|
48
|
+
#
|
49
|
+
# @method attr_instance_unique_array
|
50
|
+
#
|
51
|
+
# @overload attr_instance_unique_array( *names )
|
52
|
+
#
|
53
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
54
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
55
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
56
|
+
#
|
57
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
58
|
+
# and runs module_eval( & block ) on instance with provided block.
|
59
|
+
#
|
60
|
+
# @return self
|
61
|
+
#
|
62
|
+
|
63
|
+
###
|
64
|
+
# Non-cascading array methods that will affect the instance declared on as well as instances of that instance,
|
65
|
+
# if applicable.
|
66
|
+
#
|
67
|
+
# @method attr_local_unique_array
|
68
|
+
#
|
69
|
+
# @overload attr_local_unique_array( *names )
|
70
|
+
#
|
71
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
72
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
73
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
74
|
+
#
|
75
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
76
|
+
# and runs module_eval( & block ) on instance with provided block.
|
77
|
+
#
|
78
|
+
# @return self
|
79
|
+
#
|
80
|
+
|
81
|
+
###
|
82
|
+
# Non-cascading array methods that will affect only the instance declared on.
|
83
|
+
#
|
84
|
+
# @method attr_object_unique_array
|
85
|
+
#
|
86
|
+
# @overload attr_object_unique_array( *names )
|
87
|
+
#
|
88
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
89
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
90
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
91
|
+
#
|
92
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
93
|
+
# and runs module_eval( & block ) on instance with provided block.
|
94
|
+
#
|
95
|
+
# @return self
|
96
|
+
#
|
97
|
+
|
98
|
+
unique_array_module = ::CascadingConfiguration::Core::Module::ExtendedConfigurations::
|
99
|
+
CompositingObjects.new( :unique_array,
|
100
|
+
::CompositingArray::Unique,
|
101
|
+
:default,
|
102
|
+
:configuration_unique_array )
|
103
|
+
|
104
|
+
::CascadingConfiguration::Core.enable( self, unique_array_module )
|
105
|
+
|
106
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
|
2
|
+
###
|
3
|
+
# CascadingConfiguration::Array allows definition of array attributes that will composite downward through
|
4
|
+
# the ancestor chain.
|
5
|
+
#
|
6
|
+
module ::CascadingConfiguration::Array
|
7
|
+
|
8
|
+
###
|
9
|
+
# Cascading array attribute methods, which will affect instances according to include/extend pattern used.
|
10
|
+
#
|
11
|
+
# @method attr_array
|
12
|
+
#
|
13
|
+
# @overload attr_array( *names )
|
14
|
+
#
|
15
|
+
# @scope
|
16
|
+
#
|
17
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String},Module] name The name to be used
|
18
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
19
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
20
|
+
#
|
21
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
22
|
+
# and runs module_eval( & block ) on instance with provided block.
|
23
|
+
#
|
24
|
+
# @return self
|
25
|
+
#
|
26
|
+
|
27
|
+
###
|
28
|
+
# Cascading array attribute module/class methods, which will affect all module singletons
|
29
|
+
# according to include/extend pattern used.
|
30
|
+
#
|
31
|
+
# @method attr_module_array
|
32
|
+
#
|
33
|
+
# @overload attr_module_array( *names )
|
34
|
+
#
|
35
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
36
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
37
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
38
|
+
#
|
39
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
40
|
+
# and runs module_eval( & block ) on instance with provided block.
|
41
|
+
#
|
42
|
+
# @return self
|
43
|
+
#
|
44
|
+
|
45
|
+
###
|
46
|
+
# Cascading array instance methods, which will affect instances of including modules according to
|
47
|
+
# include/extend pattern used.
|
48
|
+
#
|
49
|
+
# @method attr_instance_array
|
50
|
+
#
|
51
|
+
# @overload attr_instance_array( *names )
|
52
|
+
#
|
53
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
54
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
55
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
56
|
+
#
|
57
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
58
|
+
# and runs module_eval( & block ) on instance with provided block.
|
59
|
+
#
|
60
|
+
# @return self
|
61
|
+
#
|
62
|
+
|
63
|
+
###
|
64
|
+
# Non-cascading array methods that will affect the instance declared on as well as instances of that instance,
|
65
|
+
# if applicable.
|
66
|
+
#
|
67
|
+
# @method attr_local_array
|
68
|
+
#
|
69
|
+
# @overload attr_local_array( *names )
|
70
|
+
#
|
71
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
72
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
73
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
74
|
+
#
|
75
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
76
|
+
# and runs module_eval( & block ) on instance with provided block.
|
77
|
+
#
|
78
|
+
# @return self
|
79
|
+
#
|
80
|
+
|
81
|
+
###
|
82
|
+
# Non-cascading array methods that will affect only the instance declared on.
|
83
|
+
#
|
84
|
+
# @method attr_object_array
|
85
|
+
#
|
86
|
+
# @overload attr_object_array( *names )
|
87
|
+
#
|
88
|
+
# @param [Symbol,String,Hash{Symbol,String=>Symbol,String}] name The name to be used
|
89
|
+
# for the declared attribute. If a array is passed, each key will be used as the setting
|
90
|
+
# name and accessor and each value will be used as the corresponding write accessor.
|
91
|
+
#
|
92
|
+
# @yield [ ] Creates a new Module of type CascadingConfiguration::Core::InstanceController::ExtensionModule
|
93
|
+
# and runs module_eval( & block ) on instance with provided block.
|
94
|
+
#
|
95
|
+
# @return self
|
96
|
+
#
|
97
|
+
|
98
|
+
array_module = ::CascadingConfiguration::Core::Module::ExtendedConfigurations::
|
99
|
+
CompositingObjects.new( :array, ::CompositingArray, :default, :configuration_array )
|
100
|
+
|
101
|
+
::CascadingConfiguration::Core.enable( self, array_module )
|
102
|
+
|
103
|
+
end
|