module-cluster 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/module-cluster/ModuleCluster/Define/ModuleCluster.rb +43 -9
- data/lib/module-cluster/ModuleCluster/Define/ModuleClusterCascades.rb +58 -8
- data/lib/module-cluster/ModuleCluster/Define/ModuleClusterCascadesToClass.rb +74 -8
- data/lib/module-cluster/ModuleCluster/Define/ModuleClusterCascadesToModule.rb +74 -8
- data/lib/module-cluster/ModuleCluster/Define/_private_/AnonymousModule.rb +121 -0
- data/lib/module-cluster/ModuleCluster/Define/_private_/ClusterStack.rb +15 -2
- data/lib/module-cluster.rb +6 -6
- metadata +3 -10
- data/lib/module-cluster/ModuleCluster/Define/_private_/ModuleCluster.rb +0 -110
- data/lib/module-cluster/ModuleCluster/Define/_private_/ModuleClusterCascades.rb +0 -118
- data/lib/module-cluster/ModuleCluster/Define/_private_/ModuleClusterCascadesToClass.rb +0 -126
- data/lib/module-cluster/ModuleCluster/Define/_private_/ModuleClusterCascadesToModule.rb +0 -126
- data/spec/ModuleCluster/Define/_private_/ModuleClusterCascadesToClass_spec.rb +0 -249
- data/spec/ModuleCluster/Define/_private_/ModuleClusterCascadesToModule_spec.rb +0 -266
- data/spec/ModuleCluster/Define/_private_/ModuleClusterCascades_spec.rb +0 -223
- data/spec/ModuleCluster/Define/_private_/ModuleCluster_spec.rb +0 -168
@@ -1,12 +1,18 @@
|
|
1
1
|
|
2
2
|
module ModuleCluster::Define::ModuleCluster
|
3
|
-
|
3
|
+
|
4
|
+
include ModuleCluster::Define::AnonymousModule
|
5
|
+
|
4
6
|
###########################
|
5
7
|
# include_also_includes #
|
6
8
|
###########################
|
7
9
|
|
8
10
|
def include_also_includes( *includes )
|
9
|
-
includes_module =
|
11
|
+
includes_module = anonymous_module_for_included do
|
12
|
+
includes.each do |this_module|
|
13
|
+
include( this_module )
|
14
|
+
end
|
15
|
+
end
|
10
16
|
clusterstack_module { include( includes_module ) }
|
11
17
|
return self
|
12
18
|
end
|
@@ -16,7 +22,11 @@ module ModuleCluster::Define::ModuleCluster
|
|
16
22
|
##########################
|
17
23
|
|
18
24
|
def include_also_extends( *extends )
|
19
|
-
extends_module =
|
25
|
+
extends_module = anonymous_module_for_included do
|
26
|
+
extends.each do |this_module|
|
27
|
+
extend( this_module )
|
28
|
+
end
|
29
|
+
end
|
20
30
|
clusterstack_module { include( extends_module ) }
|
21
31
|
return self
|
22
32
|
end
|
@@ -36,7 +46,11 @@ module ModuleCluster::Define::ModuleCluster
|
|
36
46
|
##########################
|
37
47
|
|
38
48
|
def extend_also_includes( *includes )
|
39
|
-
includes_module =
|
49
|
+
includes_module = anonymous_module_for_extended do
|
50
|
+
includes.each do |this_module|
|
51
|
+
include( this_module )
|
52
|
+
end
|
53
|
+
end
|
40
54
|
clusterstack_module { include( includes_module ) }
|
41
55
|
return self
|
42
56
|
end
|
@@ -46,7 +60,11 @@ module ModuleCluster::Define::ModuleCluster
|
|
46
60
|
#########################
|
47
61
|
|
48
62
|
def extend_also_extends( *extends )
|
49
|
-
extends_module =
|
63
|
+
extends_module = anonymous_module_for_extended do
|
64
|
+
extends.each do |this_module|
|
65
|
+
extend( this_module )
|
66
|
+
end
|
67
|
+
end
|
50
68
|
clusterstack_module { include( extends_module ) }
|
51
69
|
return self
|
52
70
|
end
|
@@ -66,7 +84,11 @@ module ModuleCluster::Define::ModuleCluster
|
|
66
84
|
###############################
|
67
85
|
|
68
86
|
def include_prepends_includes( *includes )
|
69
|
-
includes_module =
|
87
|
+
includes_module = anonymous_module_for_append_features do
|
88
|
+
includes.each do |this_module|
|
89
|
+
include( this_module )
|
90
|
+
end
|
91
|
+
end
|
70
92
|
clusterstack_module { include( includes_module ) }
|
71
93
|
return self
|
72
94
|
end
|
@@ -76,7 +98,11 @@ module ModuleCluster::Define::ModuleCluster
|
|
76
98
|
##############################
|
77
99
|
|
78
100
|
def include_prepends_extends( *extends )
|
79
|
-
extends_module =
|
101
|
+
extends_module = anonymous_module_for_append_features do
|
102
|
+
extends.each do |this_module|
|
103
|
+
extend( this_module )
|
104
|
+
end
|
105
|
+
end
|
80
106
|
clusterstack_module { include( extends_module ) }
|
81
107
|
return self
|
82
108
|
end
|
@@ -96,7 +122,11 @@ module ModuleCluster::Define::ModuleCluster
|
|
96
122
|
##############################
|
97
123
|
|
98
124
|
def extend_prepends_includes( *includes )
|
99
|
-
includes_module =
|
125
|
+
includes_module = anonymous_module_for_extend_object do
|
126
|
+
includes.each do |this_module|
|
127
|
+
include( this_module )
|
128
|
+
end
|
129
|
+
end
|
100
130
|
clusterstack_module { include( includes_module ) }
|
101
131
|
return self
|
102
132
|
end
|
@@ -106,7 +136,11 @@ module ModuleCluster::Define::ModuleCluster
|
|
106
136
|
#############################
|
107
137
|
|
108
138
|
def extend_prepends_extends( *extends )
|
109
|
-
extends_module =
|
139
|
+
extends_module = anonymous_module_for_extend_object do
|
140
|
+
extends.each do |this_module|
|
141
|
+
extend( this_module )
|
142
|
+
end
|
143
|
+
end
|
110
144
|
clusterstack_module { include( extends_module ) }
|
111
145
|
return self
|
112
146
|
end
|
@@ -1,12 +1,20 @@
|
|
1
1
|
|
2
2
|
module ModuleCluster::Define::ModuleClusterCascades
|
3
3
|
|
4
|
+
include ModuleCluster::Define::AnonymousModule
|
5
|
+
|
4
6
|
###############################
|
5
7
|
# include_cascades_includes #
|
6
8
|
###############################
|
7
9
|
|
8
10
|
def include_cascades_includes( *includes )
|
9
|
-
includes_module =
|
11
|
+
includes_module = anonymous_module_for_included do
|
12
|
+
extend ModuleCluster::Define::ModuleClusterCascades
|
13
|
+
include_cascades_includes( *includes )
|
14
|
+
includes.each do |this_module|
|
15
|
+
include( this_module )
|
16
|
+
end
|
17
|
+
end
|
10
18
|
clusterstack_module { include( includes_module ) }
|
11
19
|
return self
|
12
20
|
end
|
@@ -16,7 +24,13 @@ module ModuleCluster::Define::ModuleClusterCascades
|
|
16
24
|
##############################
|
17
25
|
|
18
26
|
def include_cascades_extends( *extends )
|
19
|
-
extends_module =
|
27
|
+
extends_module = anonymous_module_for_included do
|
28
|
+
extend ModuleCluster::Define::ModuleClusterCascades
|
29
|
+
include_cascades_extends( *extends )
|
30
|
+
extends.each do |this_module|
|
31
|
+
extend( this_module )
|
32
|
+
end
|
33
|
+
end
|
20
34
|
clusterstack_module { include( extends_module ) }
|
21
35
|
return self
|
22
36
|
end
|
@@ -36,7 +50,13 @@ module ModuleCluster::Define::ModuleClusterCascades
|
|
36
50
|
##############################
|
37
51
|
|
38
52
|
def extend_cascades_includes( *includes )
|
39
|
-
includes_module =
|
53
|
+
includes_module = anonymous_module_for_extended do
|
54
|
+
extend ModuleCluster::Define::ModuleClusterCascades
|
55
|
+
extend_cascades_includes( *includes )
|
56
|
+
includes.each do |this_module|
|
57
|
+
include( this_module )
|
58
|
+
end
|
59
|
+
end
|
40
60
|
clusterstack_module { include( includes_module ) }
|
41
61
|
return self
|
42
62
|
end
|
@@ -46,7 +66,13 @@ module ModuleCluster::Define::ModuleClusterCascades
|
|
46
66
|
#############################
|
47
67
|
|
48
68
|
def extend_cascades_extends( *extends )
|
49
|
-
extends_module =
|
69
|
+
extends_module = anonymous_module_for_extended do
|
70
|
+
extend ModuleCluster::Define::ModuleClusterCascades
|
71
|
+
extend_cascades_extends( *extends )
|
72
|
+
extends.each do |this_module|
|
73
|
+
extend( this_module )
|
74
|
+
end
|
75
|
+
end
|
50
76
|
clusterstack_module { include( extends_module ) }
|
51
77
|
return self
|
52
78
|
end
|
@@ -66,7 +92,13 @@ module ModuleCluster::Define::ModuleClusterCascades
|
|
66
92
|
##########################################
|
67
93
|
|
68
94
|
def include_cascades_prepending_includes( *includes )
|
69
|
-
includes_module =
|
95
|
+
includes_module = anonymous_module_for_append_features do
|
96
|
+
extend ModuleCluster::Define::ModuleClusterCascades
|
97
|
+
include_cascades_prepending_includes( *includes )
|
98
|
+
includes.each do |this_module|
|
99
|
+
include( this_module )
|
100
|
+
end
|
101
|
+
end
|
70
102
|
clusterstack_module { include( includes_module ) }
|
71
103
|
return self
|
72
104
|
end
|
@@ -76,7 +108,13 @@ module ModuleCluster::Define::ModuleClusterCascades
|
|
76
108
|
#########################################
|
77
109
|
|
78
110
|
def include_cascades_prepending_extends( *extends )
|
79
|
-
extends_module =
|
111
|
+
extends_module = anonymous_module_for_append_features do
|
112
|
+
extend ModuleCluster::Define::ModuleClusterCascades
|
113
|
+
include_cascades_prepending_extends( *extends )
|
114
|
+
extends.each do |this_module|
|
115
|
+
extend( this_module )
|
116
|
+
end
|
117
|
+
end
|
80
118
|
clusterstack_module { include( extends_module ) }
|
81
119
|
return self
|
82
120
|
end
|
@@ -96,7 +134,13 @@ module ModuleCluster::Define::ModuleClusterCascades
|
|
96
134
|
#########################################
|
97
135
|
|
98
136
|
def extend_cascades_prepending_includes( *includes )
|
99
|
-
includes_module =
|
137
|
+
includes_module = anonymous_module_for_extend_object do
|
138
|
+
extend ModuleCluster::Define::ModuleClusterCascades
|
139
|
+
extend_cascades_prepending_includes( *includes )
|
140
|
+
includes.each do |this_module|
|
141
|
+
include( this_module )
|
142
|
+
end
|
143
|
+
end
|
100
144
|
clusterstack_module { include( includes_module ) }
|
101
145
|
return self
|
102
146
|
end
|
@@ -106,7 +150,13 @@ module ModuleCluster::Define::ModuleClusterCascades
|
|
106
150
|
########################################
|
107
151
|
|
108
152
|
def extend_cascades_prepending_extends( *extends )
|
109
|
-
extends_module =
|
153
|
+
extends_module = anonymous_module_for_extend_object do
|
154
|
+
extend ModuleCluster::Define::ModuleClusterCascades
|
155
|
+
extend_cascades_prepending_extends( *extends )
|
156
|
+
extends.each do |this_module|
|
157
|
+
extend( this_module )
|
158
|
+
end
|
159
|
+
end
|
110
160
|
clusterstack_module { include( extends_module ) }
|
111
161
|
return self
|
112
162
|
end
|
@@ -1,12 +1,22 @@
|
|
1
1
|
|
2
2
|
module ModuleCluster::Define::ModuleClusterCascadesToClass
|
3
3
|
|
4
|
+
include ModuleCluster::Define::AnonymousModule
|
5
|
+
|
4
6
|
########################################
|
5
7
|
# include_cascades_includes_to_class #
|
6
8
|
########################################
|
7
9
|
|
8
10
|
def include_cascades_includes_to_class( *includes )
|
9
|
-
includes_module =
|
11
|
+
includes_module = anonymous_module_for_included do
|
12
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToClass
|
13
|
+
include_cascades_includes_to_class( *includes )
|
14
|
+
if is_a?( Class )
|
15
|
+
includes.each do |this_module|
|
16
|
+
include( this_module )
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
10
20
|
clusterstack_module { include( includes_module ) }
|
11
21
|
return self
|
12
22
|
end
|
@@ -16,7 +26,15 @@ module ModuleCluster::Define::ModuleClusterCascadesToClass
|
|
16
26
|
#######################################
|
17
27
|
|
18
28
|
def include_cascades_extends_to_class( *extends )
|
19
|
-
extends_module =
|
29
|
+
extends_module = anonymous_module_for_included do
|
30
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToClass
|
31
|
+
include_cascades_extends_to_class( *extends )
|
32
|
+
if is_a?( Class )
|
33
|
+
extends.each do |this_module|
|
34
|
+
extend( this_module )
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
20
38
|
clusterstack_module { include( extends_module ) }
|
21
39
|
return self
|
22
40
|
end
|
@@ -36,7 +54,15 @@ module ModuleCluster::Define::ModuleClusterCascadesToClass
|
|
36
54
|
#######################################
|
37
55
|
|
38
56
|
def extend_cascades_includes_to_class( *includes )
|
39
|
-
includes_module =
|
57
|
+
includes_module = anonymous_module_for_extended do
|
58
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToClass
|
59
|
+
extend_cascades_includes_to_class( *includes )
|
60
|
+
if is_a?( Class )
|
61
|
+
includes.each do |this_module|
|
62
|
+
include( this_module )
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
40
66
|
clusterstack_module { include( includes_module ) }
|
41
67
|
return self
|
42
68
|
end
|
@@ -46,7 +72,15 @@ module ModuleCluster::Define::ModuleClusterCascadesToClass
|
|
46
72
|
######################################
|
47
73
|
|
48
74
|
def extend_cascades_extends_to_class( *extends )
|
49
|
-
extends_module =
|
75
|
+
extends_module = anonymous_module_for_extended do
|
76
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToClass
|
77
|
+
extend_cascades_extends_to_class( *extends )
|
78
|
+
if is_a?( Class )
|
79
|
+
extends.each do |this_module|
|
80
|
+
extend( this_module )
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
50
84
|
clusterstack_module { include( extends_module ) }
|
51
85
|
return self
|
52
86
|
end
|
@@ -66,7 +100,15 @@ module ModuleCluster::Define::ModuleClusterCascadesToClass
|
|
66
100
|
###################################################
|
67
101
|
|
68
102
|
def include_cascades_to_class_prepending_includes( *includes )
|
69
|
-
includes_module =
|
103
|
+
includes_module = anonymous_module_for_append_features do
|
104
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToClass
|
105
|
+
include_cascades_to_class_prepending_includes( *includes )
|
106
|
+
if is_a?( Class )
|
107
|
+
includes.each do |this_module|
|
108
|
+
include( this_module )
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
70
112
|
clusterstack_module { include( includes_module ) }
|
71
113
|
return self
|
72
114
|
end
|
@@ -76,7 +118,15 @@ module ModuleCluster::Define::ModuleClusterCascadesToClass
|
|
76
118
|
##################################################
|
77
119
|
|
78
120
|
def include_cascades_to_class_prepending_extends( *extends )
|
79
|
-
extends_module =
|
121
|
+
extends_module = anonymous_module_for_append_features do
|
122
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToClass
|
123
|
+
include_cascades_to_class_prepending_extends( *extends )
|
124
|
+
if is_a?( Class )
|
125
|
+
extends.each do |this_module|
|
126
|
+
extend( this_module )
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
80
130
|
clusterstack_module { include( extends_module ) }
|
81
131
|
return self
|
82
132
|
end
|
@@ -96,7 +146,15 @@ module ModuleCluster::Define::ModuleClusterCascadesToClass
|
|
96
146
|
##################################################
|
97
147
|
|
98
148
|
def extend_cascades_to_class_prepending_includes( *includes )
|
99
|
-
includes_module =
|
149
|
+
includes_module = anonymous_module_for_extend_object do
|
150
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToClass
|
151
|
+
extend_cascades_to_class_prepending_includes( *includes )
|
152
|
+
if is_a?( Class )
|
153
|
+
includes.each do |this_module|
|
154
|
+
include( this_module )
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
100
158
|
clusterstack_module { include( includes_module ) }
|
101
159
|
return self
|
102
160
|
end
|
@@ -106,7 +164,15 @@ module ModuleCluster::Define::ModuleClusterCascadesToClass
|
|
106
164
|
#################################################
|
107
165
|
|
108
166
|
def extend_cascades_to_class_prepending_extends( *extends )
|
109
|
-
extends_module =
|
167
|
+
extends_module = anonymous_module_for_extend_object do
|
168
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToClass
|
169
|
+
extend_cascades_to_class_prepending_extends( *extends )
|
170
|
+
if is_a?( Class )
|
171
|
+
extends.each do |this_module|
|
172
|
+
extend( this_module )
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
110
176
|
clusterstack_module { include( extends_module ) }
|
111
177
|
return self
|
112
178
|
end
|
@@ -1,12 +1,22 @@
|
|
1
1
|
|
2
2
|
module ModuleCluster::Define::ModuleClusterCascadesToModule
|
3
3
|
|
4
|
+
include ModuleCluster::Define::AnonymousModule
|
5
|
+
|
4
6
|
#########################################
|
5
7
|
# include_cascades_includes_to_module #
|
6
8
|
#########################################
|
7
9
|
|
8
10
|
def include_cascades_includes_to_module( *includes )
|
9
|
-
includes_module =
|
11
|
+
includes_module = anonymous_module_for_included do
|
12
|
+
unless is_a?( Class )
|
13
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToModule
|
14
|
+
include_cascades_includes_to_module( *includes )
|
15
|
+
includes.each do |this_module|
|
16
|
+
include( this_module )
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
10
20
|
clusterstack_module { include( includes_module ) }
|
11
21
|
return self
|
12
22
|
end
|
@@ -16,7 +26,15 @@ module ModuleCluster::Define::ModuleClusterCascadesToModule
|
|
16
26
|
########################################
|
17
27
|
|
18
28
|
def include_cascades_extends_to_module( *extends )
|
19
|
-
extends_module =
|
29
|
+
extends_module = anonymous_module_for_included do
|
30
|
+
unless is_a?( Class )
|
31
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToModule
|
32
|
+
include_cascades_extends_to_module( *extends )
|
33
|
+
extends.each do |this_module|
|
34
|
+
extend( this_module )
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
20
38
|
clusterstack_module { include( extends_module ) }
|
21
39
|
return self
|
22
40
|
end
|
@@ -36,7 +54,15 @@ module ModuleCluster::Define::ModuleClusterCascadesToModule
|
|
36
54
|
########################################
|
37
55
|
|
38
56
|
def extend_cascades_includes_to_module( *includes )
|
39
|
-
includes_module =
|
57
|
+
includes_module = anonymous_module_for_extended do
|
58
|
+
unless is_a?( Class )
|
59
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToModule
|
60
|
+
extend_cascades_includes_to_module( *includes )
|
61
|
+
includes.each do |this_module|
|
62
|
+
include( this_module )
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
40
66
|
clusterstack_module { include( includes_module ) }
|
41
67
|
return self
|
42
68
|
end
|
@@ -46,7 +72,15 @@ module ModuleCluster::Define::ModuleClusterCascadesToModule
|
|
46
72
|
#######################################
|
47
73
|
|
48
74
|
def extend_cascades_extends_to_module( *extends )
|
49
|
-
extends_module =
|
75
|
+
extends_module = anonymous_module_for_extended do
|
76
|
+
unless is_a?( Class )
|
77
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToModule
|
78
|
+
extend_cascades_extends_to_module( *extends )
|
79
|
+
extends.each do |this_module|
|
80
|
+
extend( this_module )
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
50
84
|
clusterstack_module { include( extends_module ) }
|
51
85
|
return self
|
52
86
|
end
|
@@ -66,7 +100,15 @@ module ModuleCluster::Define::ModuleClusterCascadesToModule
|
|
66
100
|
####################################################
|
67
101
|
|
68
102
|
def include_cascades_to_module_prepending_includes( *includes )
|
69
|
-
includes_module =
|
103
|
+
includes_module = anonymous_module_for_append_features do
|
104
|
+
unless is_a?( Class )
|
105
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToModule
|
106
|
+
include_cascades_to_module_prepending_includes( *includes )
|
107
|
+
includes.each do |this_module|
|
108
|
+
include( this_module )
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
70
112
|
clusterstack_module { include( includes_module ) }
|
71
113
|
return self
|
72
114
|
end
|
@@ -76,7 +118,15 @@ module ModuleCluster::Define::ModuleClusterCascadesToModule
|
|
76
118
|
###################################################
|
77
119
|
|
78
120
|
def include_cascades_to_module_prepending_extends( *extends )
|
79
|
-
extends_module =
|
121
|
+
extends_module = anonymous_module_for_append_features do
|
122
|
+
unless is_a?( Class )
|
123
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToModule
|
124
|
+
include_cascades_to_module_prepending_extends( *extends )
|
125
|
+
extends.each do |this_module|
|
126
|
+
extend( this_module )
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
80
130
|
clusterstack_module { include( extends_module ) }
|
81
131
|
return self
|
82
132
|
end
|
@@ -96,7 +146,15 @@ module ModuleCluster::Define::ModuleClusterCascadesToModule
|
|
96
146
|
###################################################
|
97
147
|
|
98
148
|
def extend_cascades_to_module_prepending_includes( *includes )
|
99
|
-
includes_module =
|
149
|
+
includes_module = anonymous_module_for_extend_object do
|
150
|
+
unless is_a?( Class )
|
151
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToModule
|
152
|
+
extend_cascades_to_module_prepending_includes( *includes )
|
153
|
+
includes.each do |this_module|
|
154
|
+
include( this_module )
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
100
158
|
clusterstack_module { include( includes_module ) }
|
101
159
|
return self
|
102
160
|
end
|
@@ -106,7 +164,15 @@ module ModuleCluster::Define::ModuleClusterCascadesToModule
|
|
106
164
|
##################################################
|
107
165
|
|
108
166
|
def extend_cascades_to_module_prepending_extends( *extends )
|
109
|
-
extends_module =
|
167
|
+
extends_module = anonymous_module_for_extend_object do
|
168
|
+
unless is_a?( Class )
|
169
|
+
extend ModuleCluster::Define::ModuleClusterCascadesToModule
|
170
|
+
extend_cascades_to_module_prepending_extends( *extends )
|
171
|
+
extends.each do |this_module|
|
172
|
+
extend( this_module )
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
110
176
|
clusterstack_module { include( extends_module ) }
|
111
177
|
return self
|
112
178
|
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
|
2
|
+
module ModuleCluster::Define::AnonymousModule
|
3
|
+
|
4
|
+
###########################################################################################################
|
5
|
+
private ###############################################################################################
|
6
|
+
###########################################################################################################
|
7
|
+
|
8
|
+
include ModuleCluster::Define::ClusterStack
|
9
|
+
|
10
|
+
##########################################
|
11
|
+
# anonymous_module_for_append_features #
|
12
|
+
##########################################
|
13
|
+
|
14
|
+
def anonymous_module_for_append_features( & method_block )
|
15
|
+
|
16
|
+
module_instance = Module.new do
|
17
|
+
|
18
|
+
#-------------------#
|
19
|
+
# append_features #
|
20
|
+
#-------------------#
|
21
|
+
|
22
|
+
define_method( :append_features ) do |class_or_module|
|
23
|
+
class_or_module.module_eval( & method_block )
|
24
|
+
super( class_or_module )
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
set_anonymous_module_constant( 'AppendFeatures', module_instance )
|
30
|
+
|
31
|
+
return module_instance
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
###################################
|
36
|
+
# anonymous_module_for_included #
|
37
|
+
###################################
|
38
|
+
|
39
|
+
def anonymous_module_for_included( & method_block )
|
40
|
+
|
41
|
+
module_instance = Module.new do
|
42
|
+
|
43
|
+
#------------#
|
44
|
+
# included #
|
45
|
+
#------------#
|
46
|
+
|
47
|
+
define_method( :included ) do |class_or_module|
|
48
|
+
super( class_or_module )
|
49
|
+
class_or_module.module_eval( & method_block )
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
set_anonymous_module_constant( 'Included', module_instance )
|
55
|
+
|
56
|
+
return module_instance
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
########################################
|
61
|
+
# anonymous_module_for_extend_object #
|
62
|
+
########################################
|
63
|
+
|
64
|
+
def anonymous_module_for_extend_object( & method_block )
|
65
|
+
|
66
|
+
module_instance = Module.new do
|
67
|
+
|
68
|
+
#-----------------#
|
69
|
+
# extend_object #
|
70
|
+
#-----------------#
|
71
|
+
|
72
|
+
define_method( :extend_object ) do |class_or_module|
|
73
|
+
class_or_module.module_eval( & method_block )
|
74
|
+
super( class_or_module )
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
set_anonymous_module_constant( 'ExtendObject', module_instance )
|
80
|
+
|
81
|
+
return module_instance
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
###################################
|
86
|
+
# anonymous_module_for_extended #
|
87
|
+
###################################
|
88
|
+
|
89
|
+
def anonymous_module_for_extended( & method_block )
|
90
|
+
|
91
|
+
module_instance = Module.new do
|
92
|
+
|
93
|
+
#------------#
|
94
|
+
# extended #
|
95
|
+
#------------#
|
96
|
+
|
97
|
+
define_method( :extended ) do |class_or_module|
|
98
|
+
super( class_or_module )
|
99
|
+
class_or_module.module_eval( & method_block )
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
set_anonymous_module_constant( 'Included', module_instance )
|
105
|
+
|
106
|
+
return module_instance
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
###################################
|
111
|
+
# set_anonymous_module_constant #
|
112
|
+
###################################
|
113
|
+
|
114
|
+
def set_anonymous_module_constant( base_name, module_instance )
|
115
|
+
|
116
|
+
module_constant_name = ( base_name << clusterstack_module.increment_stack_count.to_s ).to_sym
|
117
|
+
const_set( module_constant_name, module_instance )
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
module ModuleCluster::Define::ClusterStack
|
3
|
-
|
3
|
+
|
4
4
|
###########################################################################################################
|
5
5
|
private ###############################################################################################
|
6
6
|
###########################################################################################################
|
@@ -12,7 +12,20 @@ module ModuleCluster::Define::ClusterStack
|
|
12
12
|
def clusterstack_module( & clusterstack_extend_include_block )
|
13
13
|
|
14
14
|
unless const_defined?( :ClusterStackModule )
|
15
|
-
|
15
|
+
module_instance = Module.new do
|
16
|
+
|
17
|
+
#-------------------------#
|
18
|
+
# increment_stack_count #
|
19
|
+
#-------------------------#
|
20
|
+
|
21
|
+
def self.increment_stack_count
|
22
|
+
@stack_count ||= 0
|
23
|
+
@stack_count += 1
|
24
|
+
return @stack_count
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
const_set( :ClusterStackModule, module_instance )
|
16
29
|
end
|
17
30
|
|
18
31
|
# we use a block so that we don't have to worry about re-extending each time
|
data/lib/module-cluster.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
|
2
2
|
module ModuleCluster
|
3
3
|
module Define
|
4
|
+
module AnonymousModule
|
5
|
+
end
|
4
6
|
module ClusterStack
|
5
7
|
end
|
6
8
|
module ModuleCluster
|
@@ -16,14 +18,12 @@ module ModuleCluster
|
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
|
-
require_relative 'module-cluster/ModuleCluster.rb'
|
21
|
+
require_relative 'module-cluster/ModuleCluster/Define/_private_/AnonymousModule.rb'
|
22
|
+
require_relative 'module-cluster/ModuleCluster/Define/_private_/ClusterStack.rb'
|
23
|
+
|
20
24
|
require_relative 'module-cluster/ModuleCluster/Define/ModuleCluster.rb'
|
21
25
|
require_relative 'module-cluster/ModuleCluster/Define/ModuleClusterCascades.rb'
|
22
26
|
require_relative 'module-cluster/ModuleCluster/Define/ModuleClusterCascadesToClass.rb'
|
23
27
|
require_relative 'module-cluster/ModuleCluster/Define/ModuleClusterCascadesToModule.rb'
|
24
28
|
require_relative 'module-cluster/ModuleCluster/Define/Deprecated.rb'
|
25
|
-
require_relative 'module-cluster/ModuleCluster
|
26
|
-
require_relative 'module-cluster/ModuleCluster/Define/_private_/ModuleCluster.rb'
|
27
|
-
require_relative 'module-cluster/ModuleCluster/Define/_private_/ModuleClusterCascades.rb'
|
28
|
-
require_relative 'module-cluster/ModuleCluster/Define/_private_/ModuleClusterCascadesToClass.rb'
|
29
|
-
require_relative 'module-cluster/ModuleCluster/Define/_private_/ModuleClusterCascadesToModule.rb'
|
29
|
+
require_relative 'module-cluster/ModuleCluster.rb'
|