module-cluster 1.3.7 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/README.md +146 -1
  2. data/README.rdoc +146 -1
  3. data/lib/module-cluster.rb +54 -12
  4. data/lib/module-cluster/ModuleCluster/Define/Block.rb +3 -0
  5. data/lib/module-cluster/ModuleCluster/Define/Block/Class.rb +16 -4
  6. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrInstance.rb +63 -0
  7. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModule.rb +2 -0
  8. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrInstance.rb +63 -0
  9. data/lib/module-cluster/ModuleCluster/Define/Block/Instance.rb +32 -0
  10. data/lib/module-cluster/ModuleCluster/Define/Block/Module.rb +16 -4
  11. data/lib/module-cluster/ModuleCluster/Define/Block/ModuleOrInstance.rb +63 -0
  12. data/lib/module-cluster/ModuleCluster/Define/ClassCluster.rb +200 -0
  13. data/lib/module-cluster/ModuleCluster/Define/ClassOrInstanceCluster.rb +127 -0
  14. data/lib/module-cluster/ModuleCluster/Define/Cluster.rb +7 -19
  15. data/lib/module-cluster/ModuleCluster/Define/ClusterCascades.rb +5 -20
  16. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToClass.rb +9 -26
  17. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToModule.rb +9 -26
  18. data/lib/module-cluster/ModuleCluster/Define/InstanceCluster.rb +46 -0
  19. data/lib/module-cluster/ModuleCluster/Define/ModuleCluster.rb +200 -0
  20. data/lib/module-cluster/ModuleCluster/Define/ModuleOrClassCluster.rb +208 -0
  21. data/lib/module-cluster/ModuleCluster/Define/ModuleOrInstanceCluster.rb +127 -0
  22. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures.rb +54 -0
  23. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/ClusterStack.rb +44 -0
  24. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/PerformCascades.rb +209 -0
  25. data/lib/module-cluster/{ModuleCluster → _private_/ModuleCluster}/ClusterStack.rb +0 -2
  26. data/lib/module-cluster/{ModuleCluster → _private_/ModuleCluster}/ClusterStack/Block.rb +1 -2
  27. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Class.rb +36 -0
  28. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Instance.rb +20 -0
  29. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Module.rb +36 -0
  30. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Set.rb +2 -0
  31. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Extends.rb +108 -0
  32. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Includes.rb +84 -0
  33. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsExtends.rb +108 -0
  34. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsIncludes.rb +84 -0
  35. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Set.rb +7 -0
  36. data/lib/module-cluster/{ModuleCluster → _private_/ModuleCluster}/ExtendForCascade.rb +0 -0
  37. data/spec/ModuleCluster/Define/Block/ClassOrInstance_spec.rb +230 -0
  38. data/spec/ModuleCluster/Define/Block/ClassOrModuleOrInstance_spec.rb +238 -0
  39. data/spec/ModuleCluster/Define/Block/ClassOrModule_spec.rb +231 -0
  40. data/spec/ModuleCluster/Define/Block/Class_spec.rb +224 -0
  41. data/spec/ModuleCluster/Define/Block/Instance_spec.rb +78 -0
  42. data/spec/ModuleCluster/Define/Block/ModuleOrInstance_spec.rb +54 -0
  43. data/spec/ModuleCluster/Define/Block/Module_spec.rb +224 -0
  44. data/spec/ModuleCluster/Define/Block_spec.rb +18 -0
  45. data/spec/ModuleCluster/Define/ClassCluster_spec.rb +728 -0
  46. data/spec/ModuleCluster/Define/ClassOrInstanceCluster_spec.rb +576 -0
  47. data/spec/ModuleCluster/Define/ClusterCascadesToClass_spec.rb +298 -60
  48. data/spec/ModuleCluster/Define/ClusterCascadesToModule_spec.rb +307 -61
  49. data/spec/ModuleCluster/Define/ClusterCascades_spec.rb +335 -36
  50. data/spec/ModuleCluster/Define/Cluster_spec.rb +447 -14
  51. data/spec/ModuleCluster/Define/InstanceCluster_spec.rb +102 -0
  52. data/spec/ModuleCluster/Define/ModuleCluster_spec.rb +728 -0
  53. data/spec/ModuleCluster/Define/ModuleOrClassCluster_spec.rb +728 -0
  54. data/spec/ModuleCluster/Define/ModuleOrInstanceCluster_spec.rb +576 -0
  55. data/spec/_private_/ModuleCluster/CascadeFeatures/PerformCascades_spec.rb +278 -0
  56. metadata +42 -13
  57. data/lib/module-cluster/ModuleCluster/CascadeFeatures.rb +0 -197
  58. data/lib/module-cluster/ModuleCluster/ClusterStack/Block/Class.rb +0 -36
  59. data/lib/module-cluster/ModuleCluster/ClusterStack/Block/Module.rb +0 -36
  60. data/lib/module-cluster/ModuleCluster/ClusterStack/Extends.rb +0 -29
  61. data/lib/module-cluster/ModuleCluster/ClusterStack/Includes.rb +0 -28
  62. data/lib/module-cluster/ModuleCluster/ClusterStack/PrependsExtends.rb +0 -28
  63. data/lib/module-cluster/ModuleCluster/ClusterStack/PrependsIncludes.rb +0 -28
  64. data/lib/module-cluster/ModuleCluster/Define/ClusterStack.rb +0 -26
@@ -0,0 +1,127 @@
1
+
2
+ module ModuleCluster::Define::ClassOrInstanceCluster
3
+
4
+ include ModuleCluster::CascadeFeatures::ClusterStack
5
+
6
+ extend ModuleCluster::ExtendForCascade
7
+
8
+ ####################################
9
+ # self.should_include_or_extend? #
10
+ ####################################
11
+
12
+ def self.should_include_or_extend?( hooked_instance )
13
+ return hooked_instance.is_a?( Class ) || ! hooked_instance.is_a?( Module )
14
+ end
15
+
16
+ ##########################
17
+ # self.should_cascade? #
18
+ ##########################
19
+
20
+ def self.should_cascade?( class_or_instance_or_module )
21
+ return false
22
+ end
23
+
24
+ #########################################################################
25
+ # class_include_or_extend_or_instance_extend_also_includes_or_extends #
26
+ #########################################################################
27
+
28
+ def class_include_or_extend_or_instance_extend_also_includes_or_extends( *includes_or_extends, & runtime_includes_or_extends_block )
29
+ cluster_stack.class_include_includes( ModuleCluster::Define::ClassOrInstanceCluster, __method__, includes_or_extends, runtime_includes_or_extends_block )
30
+ cluster_stack.class_extend_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, includes_or_extends, runtime_includes_or_extends_block )
31
+ cluster_stack.instance_extend_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, includes_or_extends, runtime_includes_or_extends_block )
32
+ return self
33
+ end
34
+
35
+ #############################################################
36
+ # class_include_or_extend_or_instance_extend_also_extends #
37
+ #############################################################
38
+
39
+ def class_include_or_extend_or_instance_extend_also_extends( *includes_or_extends, & runtime_includes_or_extends_block )
40
+ cluster_stack.class_include_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, includes_or_extends, runtime_includes_or_extends_block )
41
+ cluster_stack.class_extend_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, includes_or_extends, runtime_includes_or_extends_block )
42
+ cluster_stack.instance_extend_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, includes_or_extends, runtime_includes_or_extends_block )
43
+ return self
44
+ end
45
+
46
+ ###############################################################
47
+ # class_include_or_instance_extend_also_includes_or_extends #
48
+ ###############################################################
49
+
50
+ def class_include_or_instance_extend_also_includes_or_extends( *includes_or_extends, & runtime_includes_or_extends_block )
51
+ cluster_stack.class_include_includes( ModuleCluster::Define::ClassOrInstanceCluster, __method__, includes_or_extends, runtime_includes_or_extends_block )
52
+ cluster_stack.instance_extend_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, includes_or_extends, runtime_includes_or_extends_block )
53
+ return self
54
+ end
55
+
56
+ ###################################################
57
+ # class_include_or_instance_extend_also_extends #
58
+ ###################################################
59
+
60
+ def class_include_or_instance_extend_also_extends( *extends, & runtime_extends_block )
61
+ cluster_stack.class_include_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, extends, runtime_extends_block )
62
+ cluster_stack.instance_extend_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, extends, runtime_extends_block )
63
+ return self
64
+ end
65
+
66
+ ###########################################
67
+ # class_or_instance_extend_also_extends #
68
+ ###########################################
69
+
70
+ def class_or_instance_extend_also_extends( *extends, & runtime_extends_block )
71
+ cluster_stack.class_extend_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, extends, runtime_extends_block )
72
+ cluster_stack.instance_extend_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, extends, runtime_extends_block )
73
+ return self
74
+ end
75
+
76
+ #############################################################################
77
+ # class_include_or_extend_or_instance_extend_prepends_includes_or_extends #
78
+ #############################################################################
79
+
80
+ def class_include_or_extend_or_instance_extend_prepends_includes_or_extends( *includes_or_extends, & runtime_includes_or_extends_block )
81
+ cluster_stack.class_include_prepends_includes( ModuleCluster::Define::ClassOrInstanceCluster, __method__, includes_or_extends, runtime_includes_or_extends_block )
82
+ cluster_stack.class_extend_prepends_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, includes_or_extends, runtime_includes_or_extends_block )
83
+ cluster_stack.instance_extend_prepends_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, includes_or_extends, runtime_includes_or_extends_block )
84
+ return self
85
+ end
86
+
87
+ ###################################################################
88
+ # class_include_or_instance_extend_prepends_includes_or_extends #
89
+ ###################################################################
90
+
91
+ def class_include_or_instance_extend_prepends_includes_or_extends( *includes_or_extends, & runtime_includes_or_extends_block )
92
+ cluster_stack.class_include_prepends_includes( ModuleCluster::Define::ClassOrInstanceCluster, __method__, includes_or_extends, runtime_includes_or_extends_block )
93
+ cluster_stack.instance_extend_prepends_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, includes_or_extends, runtime_includes_or_extends_block )
94
+ return self
95
+ end
96
+
97
+ #################################################################
98
+ # class_include_or_extend_or_instance_extend_prepends_extends #
99
+ #################################################################
100
+
101
+ def class_include_or_extend_or_instance_extend_prepends_extends( *includes_or_extends, & runtime_includes_or_extends_block )
102
+ cluster_stack.class_include_prepends_includes( ModuleCluster::Define::ClassOrInstanceCluster, __method__, includes_or_extends, runtime_includes_or_extends_block )
103
+ cluster_stack.instance_extend_prepends_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, includes_or_extends, runtime_includes_or_extends_block )
104
+ return self
105
+ end
106
+
107
+ #######################################################
108
+ # class_include_or_instance_extend_prepends_extends #
109
+ #######################################################
110
+
111
+ def class_include_or_instance_extend_prepends_extends( *extends, & runtime_extends_block )
112
+ cluster_stack.class_include_prepends_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, extends, runtime_extends_block )
113
+ cluster_stack.instance_extend_prepends_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, extends, runtime_extends_block )
114
+ return self
115
+ end
116
+
117
+ ###############################################
118
+ # class_or_instance_extend_prepends_extends #
119
+ ###############################################
120
+
121
+ def class_or_instance_extend_prepends_extends( *extends, & runtime_extends_block )
122
+ cluster_stack.class_extend_prepends_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, extends, runtime_extends_block )
123
+ cluster_stack.instance_extend_prepends_extends( ModuleCluster::Define::ClassOrInstanceCluster, __method__, extends, runtime_extends_block )
124
+ return self
125
+ end
126
+
127
+ end
@@ -1,7 +1,7 @@
1
1
 
2
2
  module ModuleCluster::Define::Cluster
3
3
 
4
- include ModuleCluster::Define::ClusterStack
4
+ include ModuleCluster::CascadeFeatures::ClusterStack
5
5
 
6
6
  extend ModuleCluster::ExtendForCascade
7
7
 
@@ -18,17 +18,9 @@ module ModuleCluster::Define::Cluster
18
18
  ##########################
19
19
 
20
20
  def self.should_cascade?( class_or_module )
21
- return true
22
- end
23
-
24
- ###########################
25
- # self.perform_cascades #
26
- ###########################
27
-
28
- def self.perform_cascades( class_or_module, method, modules )
29
- # nothing required
21
+ return false
30
22
  end
31
-
23
+
32
24
  ###########################
33
25
  # include_also_includes #
34
26
  ###########################
@@ -52,8 +44,7 @@ module ModuleCluster::Define::Cluster
52
44
  #######################################
53
45
 
54
46
  def include_also_includes_and_extends( *includes_and_extends, & runtime_includes_and_extends_block )
55
- include_also_includes( *includes_and_extends, & runtime_includes_and_extends_block )
56
- include_also_extends( *includes_and_extends, & runtime_includes_and_extends_block )
47
+ cluster_stack.include_includes_and_extends( ModuleCluster::Define::Cluster, __method__, includes_and_extends, runtime_includes_and_extends_block )
57
48
  return self
58
49
  end
59
50
 
@@ -80,8 +71,7 @@ module ModuleCluster::Define::Cluster
80
71
  ######################################
81
72
 
82
73
  def extend_also_includes_and_extends( *includes_and_extends, & runtime_includes_and_extends_block )
83
- extend_also_includes( *includes_and_extends, & runtime_includes_and_extends_block )
84
- extend_also_extends( *includes_and_extends, & runtime_includes_and_extends_block )
74
+ cluster_stack.extend_includes_and_extends( ModuleCluster::Define::Cluster, __method__, includes_and_extends, runtime_includes_and_extends_block )
85
75
  return self
86
76
  end
87
77
 
@@ -108,8 +98,7 @@ module ModuleCluster::Define::Cluster
108
98
  ###########################################
109
99
 
110
100
  def include_prepends_includes_and_extends( *includes_and_extends, & runtime_includes_and_extends_block )
111
- include_prepends_includes( *includes_and_extends, & runtime_includes_and_extends_block )
112
- include_prepends_extends( *includes_and_extends, & runtime_includes_and_extends_block )
101
+ cluster_stack.include_prepends_includes_and_extends( ModuleCluster::Define::Cluster, __method__, includes_and_extends, runtime_includes_and_extends_block )
113
102
  return self
114
103
  end
115
104
 
@@ -136,8 +125,7 @@ module ModuleCluster::Define::Cluster
136
125
  ##########################################
137
126
 
138
127
  def extend_prepends_includes_and_extends( *includes_and_extends, & runtime_includes_and_extends_block )
139
- extend_prepends_includes( *includes_and_extends, & runtime_includes_and_extends_block )
140
- extend_prepends_extends( *includes_and_extends, & runtime_includes_and_extends_block )
128
+ cluster_stack.extend_prepends_includes_and_extends( ModuleCluster::Define::Cluster, __method__, includes_and_extends, runtime_includes_and_extends_block )
141
129
  return self
142
130
  end
143
131
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  module ModuleCluster::Define::ClusterCascades
3
3
 
4
- include ModuleCluster::Define::ClusterStack
4
+ include ModuleCluster::CascadeFeatures::ClusterStack
5
5
 
6
6
  extend ModuleCluster::ExtendForCascade
7
7
 
@@ -9,7 +9,7 @@ module ModuleCluster::Define::ClusterCascades
9
9
  # self.should_include_or_extend? #
10
10
  ####################################
11
11
 
12
- def self.should_include_or_extend?( class_or_module )
12
+ def self.should_include_or_extend?( hooked_instance )
13
13
  return true
14
14
  end
15
15
 
@@ -17,23 +17,10 @@ module ModuleCluster::Define::ClusterCascades
17
17
  # self.should_cascade? #
18
18
  ##########################
19
19
 
20
- def self.should_cascade?( class_or_module )
20
+ def self.should_cascade?( hooked_instance )
21
21
  return true
22
22
  end
23
23
 
24
- ###########################
25
- # self.perform_cascades #
26
- ###########################
27
-
28
- def self.perform_cascades( class_or_module, method, modules )
29
- class_or_module.instance_eval do
30
- unless is_a?( Class )
31
- extend ModuleCluster::Define::ClusterCascades
32
- __send__( method, *modules )
33
- end
34
- end
35
- end
36
-
37
24
  ###############################
38
25
  # include_cascades_includes #
39
26
  ###############################
@@ -57,8 +44,7 @@ module ModuleCluster::Define::ClusterCascades
57
44
  ###########################################
58
45
 
59
46
  def include_cascades_includes_and_extends( *includes_and_extends, & runtime_includes_and_extends_block )
60
- include_cascades_includes( *includes_and_extends, & runtime_includes_and_extends_block )
61
- include_cascades_extends( *includes_and_extends, & runtime_includes_and_extends_block )
47
+ cluster_stack.include_includes_and_extends( ModuleCluster::Define::ClusterCascades, __method__, includes_and_extends, runtime_includes_and_extends_block )
62
48
  return self
63
49
  end
64
50
 
@@ -85,8 +71,7 @@ module ModuleCluster::Define::ClusterCascades
85
71
  ##########################################
86
72
 
87
73
  def extend_cascades_includes_and_extends( *includes_and_extends, & runtime_includes_and_extends_block )
88
- extend_cascades_includes( *includes_and_extends, & runtime_includes_and_extends_block )
89
- extend_cascades_extends( *includes_and_extends, & runtime_includes_and_extends_block )
74
+ cluster_stack.extend_includes_and_extends( ModuleCluster::Define::ClusterCascades, __method__, includes_and_extends, runtime_includes_and_extends_block )
90
75
  return self
91
76
  end
92
77
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  module ModuleCluster::Define::ClusterCascadesToClass
3
3
 
4
- include ModuleCluster::Define::ClusterStack
4
+ include ModuleCluster::CascadeFeatures::ClusterStack
5
5
 
6
6
  extend ModuleCluster::ExtendForCascade
7
7
 
@@ -9,29 +9,16 @@ module ModuleCluster::Define::ClusterCascadesToClass
9
9
  # self.should_include_or_extend? #
10
10
  ####################################
11
11
 
12
- def self.should_include_or_extend?( class_or_module )
13
- return class_or_module.is_a?( Class )
12
+ def self.should_include_or_extend?( hooked_instance )
13
+ return hooked_instance.is_a?( Class )
14
14
  end
15
15
 
16
16
  ##########################
17
17
  # self.should_cascade? #
18
18
  ##########################
19
19
 
20
- def self.should_cascade?( class_or_module )
21
- return ! class_or_module.is_a?( Class )
22
- end
23
-
24
- ###########################
25
- # self.perform_cascades #
26
- ###########################
27
-
28
- def self.perform_cascades( class_or_module, method, modules )
29
- class_or_module.instance_eval do
30
- unless is_a?( Class )
31
- extend ModuleCluster::Define::ClusterCascadesToClass
32
- __send__( method, *modules )
33
- end
34
- end
20
+ def self.should_cascade?( hooked_instance )
21
+ return hooked_instance.is_a?( Module ) && ! hooked_instance.is_a?( Class )
35
22
  end
36
23
 
37
24
  ########################################
@@ -57,8 +44,7 @@ module ModuleCluster::Define::ClusterCascadesToClass
57
44
  ####################################################
58
45
 
59
46
  def include_cascades_includes_and_extends_to_class( *includes_and_extends, & runtime_includes_and_extends_block )
60
- include_cascades_includes_to_class( *includes_and_extends, & runtime_includes_and_extends_block )
61
- include_cascades_extends_to_class( *includes_and_extends, & runtime_includes_and_extends_block )
47
+ cluster_stack.include_includes_and_extends( ModuleCluster::Define::ClusterCascadesToClass, __method__, includes_and_extends, runtime_includes_and_extends_block )
62
48
  return self
63
49
  end
64
50
 
@@ -85,8 +71,7 @@ module ModuleCluster::Define::ClusterCascadesToClass
85
71
  ###################################################
86
72
 
87
73
  def extend_cascades_includes_and_extends_to_class( *includes_and_extends, & runtime_includes_and_extends_block )
88
- extend_cascades_includes_to_class( *includes_and_extends, & runtime_includes_and_extends_block )
89
- extend_cascades_extends_to_class( *includes_and_extends, & runtime_includes_and_extends_block )
74
+ cluster_stack.extend_includes_and_extends( ModuleCluster::Define::ClusterCascadesToClass, __method__, includes_and_extends, runtime_includes_and_extends_block )
90
75
  return self
91
76
  end
92
77
 
@@ -113,8 +98,7 @@ module ModuleCluster::Define::ClusterCascadesToClass
113
98
  ###############################################################
114
99
 
115
100
  def include_cascades_to_class_prepending_includes_and_extends( *includes_and_extends, & runtime_includes_and_extends_block )
116
- include_cascades_to_class_prepending_includes( *includes_and_extends, & runtime_includes_and_extends_block )
117
- include_cascades_to_class_prepending_extends( *includes_and_extends, & runtime_includes_and_extends_block )
101
+ cluster_stack.include_prepends_includes_and_extends( ModuleCluster::Define::ClusterCascadesToClass, __method__, includes_and_extends, runtime_includes_and_extends_block )
118
102
  return self
119
103
  end
120
104
 
@@ -141,8 +125,7 @@ module ModuleCluster::Define::ClusterCascadesToClass
141
125
  ##############################################################
142
126
 
143
127
  def extend_cascades_to_class_prepending_includes_and_extends( *includes_and_extends, & runtime_includes_and_extends_block )
144
- extend_cascades_to_class_prepending_includes( *includes_and_extends, & runtime_includes_and_extends_block )
145
- extend_cascades_to_class_prepending_extends( *includes_and_extends, & runtime_includes_and_extends_block )
128
+ cluster_stack.extend_prepends_includes_and_extends( ModuleCluster::Define::ClusterCascadesToClass, __method__, includes_and_extends, runtime_includes_and_extends_block )
146
129
  return self
147
130
  end
148
131
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  module ModuleCluster::Define::ClusterCascadesToModule
3
3
 
4
- include ModuleCluster::Define::ClusterStack
4
+ include ModuleCluster::CascadeFeatures::ClusterStack
5
5
 
6
6
  extend ModuleCluster::ExtendForCascade
7
7
 
@@ -9,29 +9,16 @@ module ModuleCluster::Define::ClusterCascadesToModule
9
9
  # self.should_include_or_extend? #
10
10
  ####################################
11
11
 
12
- def self.should_include_or_extend?( class_or_module )
13
- return ! class_or_module.is_a?( Class )
12
+ def self.should_include_or_extend?( hooked_instance )
13
+ return hooked_instance.is_a?( Module ) && ! hooked_instance.is_a?( Class )
14
14
  end
15
15
 
16
16
  ##########################
17
17
  # self.should_cascade? #
18
18
  ##########################
19
19
 
20
- def self.should_cascade?( class_or_module )
21
- return ! class_or_module.is_a?( Class )
22
- end
23
-
24
- ###########################
25
- # self.perform_cascades #
26
- ###########################
27
-
28
- def self.perform_cascades( class_or_module, method, modules )
29
- class_or_module.instance_eval do
30
- unless is_a?( Class )
31
- extend ModuleCluster::Define::ClusterCascadesToModule
32
- __send__( method, *modules )
33
- end
34
- end
20
+ def self.should_cascade?( hooked_instance )
21
+ return hooked_instance.is_a?( Module ) && ! hooked_instance.is_a?( Class )
35
22
  end
36
23
 
37
24
  #########################################
@@ -57,8 +44,7 @@ module ModuleCluster::Define::ClusterCascadesToModule
57
44
  #####################################################
58
45
 
59
46
  def include_cascades_includes_and_extends_to_module( *includes_and_extends, & runtime_includes_and_extends_block )
60
- include_cascades_includes_to_module( *includes_and_extends, & runtime_includes_and_extends_block )
61
- include_cascades_extends_to_module( *includes_and_extends, & runtime_includes_and_extends_block )
47
+ cluster_stack.include_prepends_includes_and_extends( ModuleCluster::Define::ClusterCascadesToModule, __method__, includes_and_extends, runtime_includes_and_extends_block )
62
48
  return self
63
49
  end
64
50
 
@@ -85,8 +71,7 @@ module ModuleCluster::Define::ClusterCascadesToModule
85
71
  ####################################################
86
72
 
87
73
  def extend_cascades_includes_and_extends_to_module( *includes_and_extends, & runtime_includes_and_extends_block )
88
- extend_cascades_includes_to_module( *includes_and_extends, & runtime_includes_and_extends_block )
89
- extend_cascades_extends_to_module( *includes_and_extends, & runtime_includes_and_extends_block )
74
+ cluster_stack.extend_prepends_includes_and_extends( ModuleCluster::Define::ClusterCascadesToModule, __method__, includes_and_extends, runtime_includes_and_extends_block )
90
75
  return self
91
76
  end
92
77
 
@@ -113,8 +98,7 @@ module ModuleCluster::Define::ClusterCascadesToModule
113
98
  ################################################################
114
99
 
115
100
  def include_cascades_to_module_prepending_includes_and_extends( *includes_and_extends, & runtime_includes_and_extends_block )
116
- include_cascades_to_module_prepending_includes( *includes_and_extends, & runtime_includes_and_extends_block )
117
- include_cascades_to_module_prepending_extends( *includes_and_extends, & runtime_includes_and_extends_block )
101
+ cluster_stack.include_prepends_includes_and_extends( ModuleCluster::Define::ClusterCascadesToModule, __method__, includes_and_extends, runtime_includes_and_extends_block )
118
102
  return self
119
103
  end
120
104
 
@@ -141,8 +125,7 @@ module ModuleCluster::Define::ClusterCascadesToModule
141
125
  ###############################################################
142
126
 
143
127
  def extend_cascades_to_module_prepending_includes_and_extends( *includes_and_extends, & runtime_includes_and_extends_block )
144
- extend_cascades_to_module_prepending_includes( *includes_and_extends, & runtime_includes_and_extends_block )
145
- extend_cascades_to_module_prepending_extends( *includes_and_extends, & runtime_includes_and_extends_block )
128
+ cluster_stack.extend_prepends_includes_and_extends( ModuleCluster::Define::ClusterCascadesToModule, __method__, includes_and_extends, runtime_includes_and_extends_block )
146
129
  return self
147
130
  end
148
131
 
@@ -0,0 +1,46 @@
1
+
2
+ module ModuleCluster::Define::InstanceCluster
3
+
4
+ include ModuleCluster::CascadeFeatures::ClusterStack
5
+
6
+ extend ModuleCluster::ExtendForCascade
7
+
8
+ ####################################
9
+ # self.should_include_or_extend? #
10
+ ####################################
11
+
12
+ def self.should_include_or_extend?( hooked_instance )
13
+ should_include_or_extend = false
14
+ unless hooked_instance.is_a?( Module )
15
+ should_include_or_extend = true
16
+ end
17
+ return should_include_or_extend
18
+ end
19
+
20
+ ##########################
21
+ # self.should_cascade? #
22
+ ##########################
23
+
24
+ def self.should_cascade?( hooked_instance )
25
+ return false
26
+ end
27
+
28
+ ##################################
29
+ # instance_extend_also_extends #
30
+ ##################################
31
+
32
+ def instance_extend_also_extends( *extends, & runtime_extends_block )
33
+ cluster_stack.instance_extend_extends( ModuleCluster::Define::Cluster, __method__, extends, runtime_extends_block )
34
+ return self
35
+ end
36
+
37
+ ######################################
38
+ # instance_extend_prepends_extends #
39
+ ######################################
40
+
41
+ def instance_extend_prepends_extends( *extends, & runtime_extends_block )
42
+ cluster_stack.instance_extend_prepends_extends( ModuleCluster::Define::Cluster, __method__, extends, runtime_extends_block )
43
+ return self
44
+ end
45
+
46
+ end