module-cluster 1.4.8 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/README.md +127 -337
  2. data/lib/module-cluster.rb +1 -153
  3. data/lib/module/cluster.rb +341 -0
  4. data/lib/module/cluster/class_support.rb +22 -0
  5. data/lib/module/cluster/cluster.rb +10 -0
  6. data/lib/module/cluster/cluster/cluster_interface.rb +550 -0
  7. data/lib/module/cluster/exception/module_not_in_stack.rb +26 -0
  8. data/lib/module/cluster/instance_controller.rb +14 -0
  9. data/lib/module/cluster/instance_controller/hook_controller.rb +33 -0
  10. data/lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb +511 -0
  11. data/lib/module/cluster/instance_controller/hook_controller/hook_controller_interface.rb +830 -0
  12. data/lib/module/cluster/instance_controller/instance_controller_interface.rb +269 -0
  13. data/lib/module/cluster/instance_controller/multiple_hook_controller_proxy.rb +359 -0
  14. data/lib/module/cluster/instance_controller/multiple_hook_controller_proxy/chain_proxy.rb +442 -0
  15. data/lib/module/cluster/module_support.rb +67 -0
  16. data/lib/module/namespaces.rb +13 -0
  17. data/lib/module/requires.rb +32 -0
  18. data/spec/module/cluster/cluster_spec.rb +473 -0
  19. data/spec/module/cluster/instance_controller/hook_controller_spec.rb +922 -0
  20. data/spec/module/cluster/instance_controller/multiple_hook_controller_proxy_spec.rb +1240 -0
  21. data/spec/module/cluster_spec.rb +1794 -0
  22. metadata +27 -98
  23. data/README.rdoc +0 -395
  24. data/lib/module-cluster/ModuleCluster.rb +0 -9
  25. data/lib/module-cluster/ModuleCluster/Define.rb +0 -12
  26. data/lib/module-cluster/ModuleCluster/Define/Block.rb +0 -9
  27. data/lib/module-cluster/ModuleCluster/Define/Block/CascadingClass.rb +0 -83
  28. data/lib/module-cluster/ModuleCluster/Define/Block/CascadingClassOrModule.rb +0 -70
  29. data/lib/module-cluster/ModuleCluster/Define/Block/CascadingModule.rb +0 -79
  30. data/lib/module-cluster/ModuleCluster/Define/Block/CascadingModuleOrSubclass.rb +0 -21
  31. data/lib/module-cluster/ModuleCluster/Define/Block/Class.rb +0 -77
  32. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrInstance.rb +0 -78
  33. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModule.rb +0 -78
  34. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrInstance.rb +0 -78
  35. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrSubclass.rb +0 -36
  36. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrSubclass.rb +0 -29
  37. data/lib/module-cluster/ModuleCluster/Define/Block/Instance.rb +0 -45
  38. data/lib/module-cluster/ModuleCluster/Define/Block/Module.rb +0 -77
  39. data/lib/module-cluster/ModuleCluster/Define/Block/ModuleOrInstance.rb +0 -78
  40. data/lib/module-cluster/ModuleCluster/Define/Block/ModuleOrSubclass.rb +0 -29
  41. data/lib/module-cluster/ModuleCluster/Define/Block/Subclass.rb +0 -56
  42. data/lib/module-cluster/ModuleCluster/Define/ClassCluster.rb +0 -193
  43. data/lib/module-cluster/ModuleCluster/Define/ClassOrInstanceCluster.rb +0 -128
  44. data/lib/module-cluster/ModuleCluster/Define/Cluster.rb +0 -181
  45. data/lib/module-cluster/ModuleCluster/Define/ClusterCascades.rb +0 -185
  46. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToClass.rb +0 -181
  47. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToModule.rb +0 -181
  48. data/lib/module-cluster/ModuleCluster/Define/Deprecated.rb +0 -40
  49. data/lib/module-cluster/ModuleCluster/Define/InstanceCluster.rb +0 -45
  50. data/lib/module-cluster/ModuleCluster/Define/ModuleCluster.rb +0 -193
  51. data/lib/module-cluster/ModuleCluster/Define/ModuleOrClassCluster.rb +0 -209
  52. data/lib/module-cluster/ModuleCluster/Define/ModuleOrInstanceCluster.rb +0 -128
  53. data/lib/module-cluster/ModuleCluster/Define/Status.rb +0 -106
  54. data/lib/module-cluster/ModuleCluster/Suspend.rb +0 -7
  55. data/lib/module-cluster/ModuleCluster/Suspend/Hooks.rb +0 -315
  56. data/lib/module-cluster/ModuleCluster/Suspend/WithoutHooks.rb +0 -153
  57. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures.rb +0 -77
  58. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/ClusterStack.rb +0 -44
  59. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/PerformCascades.rb +0 -292
  60. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/Subclass.rb +0 -24
  61. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack.rb +0 -12
  62. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block.rb +0 -9
  63. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Class.rb +0 -36
  64. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Inherited.rb +0 -20
  65. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Instance.rb +0 -20
  66. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Module.rb +0 -36
  67. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Set.rb +0 -6
  68. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Extends.rb +0 -140
  69. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Includes.rb +0 -110
  70. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsExtends.rb +0 -140
  71. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsIncludes.rb +0 -110
  72. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Set.rb +0 -35
  73. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Set/MultiSetProxy.rb +0 -359
  74. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Status.rb +0 -55
  75. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Suspend.rb +0 -199
  76. data/lib/module-cluster/_private_/ModuleCluster/ExtendForCascade.rb +0 -34
  77. data/spec/ModuleCluster/Define/Block/CascadingClassOrModule_spec.rb +0 -285
  78. data/spec/ModuleCluster/Define/Block/CascadingClass_spec.rb +0 -254
  79. data/spec/ModuleCluster/Define/Block/CascadingModuleOrSubclass_spec.rb +0 -56
  80. data/spec/ModuleCluster/Define/Block/CascadingModule_spec.rb +0 -278
  81. data/spec/ModuleCluster/Define/Block/ClassOrInstance_spec.rb +0 -230
  82. data/spec/ModuleCluster/Define/Block/ClassOrModuleOrInstance_spec.rb +0 -238
  83. data/spec/ModuleCluster/Define/Block/ClassOrModuleOrSubclass_spec.rb +0 -54
  84. data/spec/ModuleCluster/Define/Block/ClassOrModule_spec.rb +0 -231
  85. data/spec/ModuleCluster/Define/Block/ClassOrSubclass_spec.rb +0 -54
  86. data/spec/ModuleCluster/Define/Block/Class_spec.rb +0 -224
  87. data/spec/ModuleCluster/Define/Block/Instance_spec.rb +0 -78
  88. data/spec/ModuleCluster/Define/Block/ModuleOrInstance_spec.rb +0 -54
  89. data/spec/ModuleCluster/Define/Block/ModuleOrSubclass_spec.rb +0 -51
  90. data/spec/ModuleCluster/Define/Block/Module_spec.rb +0 -230
  91. data/spec/ModuleCluster/Define/Block/Subclass_spec.rb +0 -73
  92. data/spec/ModuleCluster/Define/Block_spec.rb +0 -18
  93. data/spec/ModuleCluster/Define/ClassCluster_spec.rb +0 -728
  94. data/spec/ModuleCluster/Define/ClassOrInstanceCluster_spec.rb +0 -576
  95. data/spec/ModuleCluster/Define/ClusterCascadesToClass_spec.rb +0 -659
  96. data/spec/ModuleCluster/Define/ClusterCascadesToModule_spec.rb +0 -678
  97. data/spec/ModuleCluster/Define/ClusterCascades_spec.rb +0 -644
  98. data/spec/ModuleCluster/Define/Cluster_spec.rb +0 -708
  99. data/spec/ModuleCluster/Define/InstanceCluster_spec.rb +0 -102
  100. data/spec/ModuleCluster/Define/ModuleCluster_spec.rb +0 -728
  101. data/spec/ModuleCluster/Define/ModuleOrClassCluster_spec.rb +0 -728
  102. data/spec/ModuleCluster/Define/ModuleOrInstanceCluster_spec.rb +0 -576
  103. data/spec/ModuleCluster/Suspend/Hooks_spec.rb +0 -573
  104. data/spec/ModuleCluster/Suspend/WithoutHooks_spec.rb +0 -559
  105. data/spec/ModuleCluster_spec.rb +0 -15
  106. data/spec/_private_/ModuleCluster/CascadeFeatures/PerformCascades_spec.rb +0 -386
  107. data/spec/_private_/ModuleCluster/ClusterStack/Set/MultiSetProxy_spec.rb +0 -419
  108. data/spec/_private_/ModuleCluster/ClusterStack/Suspend_spec.rb +0 -242
@@ -0,0 +1,13 @@
1
+
2
+ module ::Module::Cluster
3
+ class Cluster
4
+ end
5
+ class InstanceController
6
+ class HookController
7
+ end
8
+ end
9
+ ###
10
+ # Container for module-cluster exceptions.
11
+ module Exception
12
+ end
13
+ end
@@ -0,0 +1,32 @@
1
+
2
+ basepath = 'cluster'
3
+
4
+ files = [
5
+
6
+ 'instance_controller/hook_controller/hook_controller_interface',
7
+ 'instance_controller/hook_controller',
8
+
9
+ 'instance_controller/hook_controller/chain_proxy',
10
+
11
+ 'instance_controller/multiple_hook_controller_proxy',
12
+ 'instance_controller/multiple_hook_controller_proxy/chain_proxy',
13
+
14
+ 'instance_controller/instance_controller_interface',
15
+ 'instance_controller',
16
+
17
+ 'cluster/cluster_interface',
18
+
19
+ 'cluster',
20
+
21
+ 'exception/module_not_in_stack',
22
+
23
+ 'class_support',
24
+ 'module_support'
25
+
26
+ ]
27
+
28
+ files.each do |this_file|
29
+ require_relative( File.join( basepath, this_file ) + '.rb' )
30
+ end
31
+
32
+ require_relative( basepath + '.rb' )
@@ -0,0 +1,473 @@
1
+
2
+ require_relative '../../../lib/module/cluster.rb'
3
+
4
+ describe ::Module::Cluster::Cluster do
5
+
6
+ ################
7
+ # initialize #
8
+ # name #
9
+ ################
10
+
11
+ it 'can be created to maintain hooks in a common stack by separate named clusters' do
12
+ module ::Module::Cluster::Cluster::InitializeMock
13
+ Instance = ::Module.new
14
+ cluster_instance = ::Module::Cluster::Cluster.new( Instance, :some_cluster )
15
+ cluster_instance.instance.should == Instance
16
+ cluster_instance.name.should == :some_cluster
17
+ end
18
+ end
19
+
20
+ ####################
21
+ # before_include #
22
+ ####################
23
+
24
+ it 'can create before-include hooks' do
25
+ module ::Module::Cluster::Cluster::BeforeIncludeMock
26
+
27
+ Instance = ::Module.new
28
+ cluster_instance = ::Module::Cluster::Cluster.new( Instance, :some_cluster )
29
+
30
+ block_ran = false
31
+ block_instance = ::Proc.new do
32
+ block_ran = true
33
+ end
34
+
35
+ proxy = cluster_instance.before_include( :class, :module ).cascade_to( :class, & block_instance )
36
+
37
+ proxy.parent_hook_controller.name.should == :before_include
38
+ proxy.contexts.should == [ :class, :module ]
39
+ proxy.cascades_to.should == [ :class ]
40
+
41
+ hook_controller = proxy.parent_hook_controller
42
+ hook_controller.stack[ 0 ].module.should == nil
43
+ hook_controller.stack[ 0 ].owner.should == Instance
44
+ hook_controller.stack[ 0 ].action.should == nil
45
+ hook_controller.stack[ 0 ].context.should == [ :class, :module ]
46
+ hook_controller.stack[ 0 ].cascades.should == [ :class ]
47
+ hook_controller.stack[ 0 ].block.should == block_instance
48
+
49
+ end
50
+ end
51
+
52
+ ###################
53
+ # after_include #
54
+ ###################
55
+
56
+ it 'can create after-include hooks' do
57
+ module ::Module::Cluster::Cluster::AfterIncludeMock
58
+
59
+ Instance = ::Module.new
60
+ cluster_instance = ::Module::Cluster::Cluster.new( Instance, :some_cluster )
61
+
62
+ block_ran = false
63
+ block_instance = ::Proc.new do
64
+ block_ran = true
65
+ end
66
+
67
+ proxy = cluster_instance.after_include( :class, :module ).cascade_to( :class, & block_instance )
68
+
69
+ proxy.parent_hook_controller.name.should == :after_include
70
+ proxy.contexts.should == [ :class, :module ]
71
+ hook_controller = proxy.parent_hook_controller
72
+ hook_controller.stack[ 0 ].module.should == nil
73
+ hook_controller.stack[ 0 ].owner.should == Instance
74
+ hook_controller.stack[ 0 ].action.should == nil
75
+ hook_controller.stack[ 0 ].context.should == [ :class, :module ]
76
+ hook_controller.stack[ 0 ].cascades.should == [ :class ]
77
+ hook_controller.stack[ 0 ].block.should == block_instance
78
+
79
+ end
80
+ end
81
+
82
+ ###################
83
+ # before_extend #
84
+ ###################
85
+
86
+ it 'can create before-extend hooks' do
87
+ module ::Module::Cluster::Cluster::BeforeExtendMock
88
+
89
+ Instance = ::Module.new
90
+ cluster_instance = ::Module::Cluster::Cluster.new( Instance, :some_cluster )
91
+
92
+ block_ran = false
93
+ block_instance = ::Proc.new do
94
+ block_ran = true
95
+ end
96
+ proxy = cluster_instance.before_extend( :class, :module ).cascade_to( :class, & block_instance )
97
+
98
+ proxy.parent_hook_controller.name.should == :before_extend
99
+ proxy.contexts.should == [ :class, :module ]
100
+ hook_controller = proxy.parent_hook_controller
101
+ hook_controller.stack[ 0 ].module.should == nil
102
+ hook_controller.stack[ 0 ].owner.should == Instance
103
+ hook_controller.stack[ 0 ].action.should == nil
104
+ hook_controller.stack[ 0 ].context.should == [ :class, :module ]
105
+ hook_controller.stack[ 0 ].cascades.should == [ :class ]
106
+ hook_controller.stack[ 0 ].block.should == block_instance
107
+
108
+ end
109
+ end
110
+
111
+ ##################
112
+ # after_extend #
113
+ ##################
114
+
115
+ it 'can create after-extend hooks' do
116
+ module ::Module::Cluster::Cluster::AfterExtendMock
117
+
118
+ Instance = ::Module.new
119
+ cluster_instance = ::Module::Cluster::Cluster.new( Instance, :some_cluster )
120
+
121
+ block_ran = false
122
+ block_instance = ::Proc.new do
123
+ block_ran = true
124
+ end
125
+ proxy = cluster_instance.after_extend( :class, :module ).cascade_to( :class, & block_instance )
126
+
127
+ proxy.parent_hook_controller.name.should == :after_extend
128
+ proxy.contexts.should == [ :class, :module ]
129
+ hook_controller = proxy.parent_hook_controller
130
+ hook_controller.stack[ 0 ].module.should == nil
131
+ hook_controller.stack[ 0 ].owner.should == Instance
132
+ hook_controller.stack[ 0 ].action.should == nil
133
+ hook_controller.stack[ 0 ].context.should == [ :class, :module ]
134
+ hook_controller.stack[ 0 ].cascades.should == [ :class ]
135
+ hook_controller.stack[ 0 ].block.should == block_instance
136
+
137
+ end
138
+ end
139
+
140
+ ##############
141
+ # subclass #
142
+ ##############
143
+
144
+ it 'can create subclass hooks' do
145
+ module ::Module::Cluster::Cluster::SubclassMock
146
+
147
+ Instance = ::Module.new
148
+ cluster_instance = ::Module::Cluster::Cluster.new( Instance, :some_cluster )
149
+
150
+ block_ran = false
151
+ block_instance = ::Proc.new do
152
+ block_ran = true
153
+ end
154
+ proxy = cluster_instance.subclass( & block_instance )
155
+
156
+ proxy.parent_hook_controller.name.should == :subclass
157
+ proxy.contexts.should == [ ]
158
+ hook_controller = proxy.parent_hook_controller
159
+ hook_controller.stack[ 0 ].module.should == nil
160
+ hook_controller.stack[ 0 ].owner.should == Instance
161
+ hook_controller.stack[ 0 ].action.should == nil
162
+ hook_controller.stack[ 0 ].context.should == [ ]
163
+ hook_controller.stack[ 0 ].cascades.should == [ ]
164
+ hook_controller.stack[ 0 ].block.should == block_instance
165
+
166
+ end
167
+ end
168
+
169
+ ##############################
170
+ # before_include_or_extend #
171
+ # before_extend_or_include #
172
+ ##############################
173
+
174
+ it 'can create before-include-or-extend hooks' do
175
+ module ::Module::Cluster::Cluster::BeforeIncludeExtendMock
176
+
177
+ ::Module::Cluster::Cluster.instance_method( :before_include_or_extend ).should == ::Module::Cluster::Cluster.instance_method( :before_extend_or_include )
178
+
179
+ Instance = ::Module.new
180
+ cluster_instance = ::Module::Cluster::Cluster.new( Instance, :before_include_extend )
181
+
182
+ block_ran = false
183
+ block_instance = ::Proc.new do
184
+ block_ran = true
185
+ end
186
+
187
+ proxy = cluster_instance.before_include_or_extend( :class, :module ).cascade_to( :class, & block_instance )
188
+
189
+ proxy.parent_multiple_hook_controller_proxy.name.should == :before_include_extend
190
+
191
+ proxy.proxies.each do |this_proxy|
192
+ this_proxy.contexts.should == [ :class, :module ]
193
+ this_hook_controller = this_proxy.parent_hook_controller
194
+ this_hook_controller.stack[ 0 ].module.should == nil
195
+ this_hook_controller.stack[ 0 ].owner.should == Instance
196
+ this_hook_controller.stack[ 0 ].action.should == nil
197
+ this_hook_controller.stack[ 0 ].context.should == [ :class, :module ]
198
+ this_hook_controller.stack[ 0 ].cascades.should == [ :class ]
199
+ this_hook_controller.stack[ 0 ].block.should == block_instance
200
+ end
201
+
202
+ end
203
+ end
204
+
205
+ #############################
206
+ # after_include_or_extend #
207
+ # after_extend_or_include #
208
+ #############################
209
+
210
+ it 'can create after-include-or-extend hooks' do
211
+ module ::Module::Cluster::Cluster::AfterIncludeExtendMock
212
+
213
+ ::Module::Cluster::Cluster.instance_method( :after_include_or_extend ).should == ::Module::Cluster::Cluster.instance_method( :after_extend_or_include )
214
+
215
+ Instance = ::Module.new
216
+ cluster_instance = ::Module::Cluster::Cluster.new( Instance, :after_include_extend )
217
+
218
+ block_ran = false
219
+ block_instance = ::Proc.new do
220
+ block_ran = true
221
+ end
222
+
223
+ proxy = cluster_instance.after_include_or_extend( :class, :module ).cascade_to( :class, & block_instance )
224
+
225
+ proxy.parent_multiple_hook_controller_proxy.name.should == :after_include_extend
226
+
227
+ proxy.proxies.each do |this_proxy|
228
+ this_proxy.contexts.should == [ :class, :module ]
229
+ this_hook_controller = this_proxy.parent_hook_controller
230
+ this_hook_controller.stack[ 0 ].module.should == nil
231
+ this_hook_controller.stack[ 0 ].owner.should == Instance
232
+ this_hook_controller.stack[ 0 ].action.should == nil
233
+ this_hook_controller.stack[ 0 ].context.should == [ :class, :module ]
234
+ this_hook_controller.stack[ 0 ].cascades.should == [ :class ]
235
+ this_hook_controller.stack[ 0 ].block.should == block_instance
236
+ end
237
+
238
+ end
239
+ end
240
+
241
+ ################################
242
+ # before_include_or_subclass #
243
+ # before_subclass_or_include #
244
+ ################################
245
+
246
+ it 'can create before-include-or-subclass hooks' do
247
+ module ::Module::Cluster::Cluster::BeforeIncludeSubclassMock
248
+
249
+ ::Module::Cluster::Cluster.instance_method( :before_include_or_subclass ).should == ::Module::Cluster::Cluster.instance_method( :before_subclass_or_include )
250
+
251
+ Instance = ::Module.new
252
+ cluster_instance = ::Module::Cluster::Cluster.new( Instance, :before_include_subclass )
253
+
254
+ block_ran = false
255
+ block_instance = ::Proc.new do
256
+ block_ran = true
257
+ end
258
+
259
+ proxy = cluster_instance.before_include_or_subclass( :class, :module ).cascade_to( :class, & block_instance )
260
+
261
+ proxy.parent_multiple_hook_controller_proxy.name.should == :before_include_subclass
262
+
263
+ proxy.proxies.each do |this_proxy|
264
+ this_proxy.contexts.should == [ :class, :module ]
265
+ this_hook_controller = this_proxy.parent_hook_controller
266
+ this_hook_controller.stack[ 0 ].module.should == nil
267
+ this_hook_controller.stack[ 0 ].owner.should == Instance
268
+ this_hook_controller.stack[ 0 ].action.should == nil
269
+ this_hook_controller.stack[ 0 ].context.should == [ :class, :module ]
270
+ this_hook_controller.stack[ 0 ].cascades.should == [ :class ]
271
+ this_hook_controller.stack[ 0 ].block.should == block_instance
272
+ end
273
+
274
+ end
275
+ end
276
+
277
+ ###############################
278
+ # after_include_or_subclass #
279
+ # after_subclass_or_include #
280
+ ###############################
281
+
282
+ it 'can create after-include-or-subclass hooks' do
283
+ module ::Module::Cluster::Cluster::AfterIncludeSubclassMock
284
+
285
+ ::Module::Cluster::Cluster.instance_method( :after_include_or_subclass ).should == ::Module::Cluster::Cluster.instance_method( :after_subclass_or_include )
286
+
287
+ Instance = ::Module.new
288
+ cluster_instance = ::Module::Cluster::Cluster.new( Instance, :after_include_subclass )
289
+
290
+ block_ran = false
291
+ block_instance = ::Proc.new do
292
+ block_ran = true
293
+ end
294
+
295
+ proxy = cluster_instance.after_include_or_subclass( :class, :module ).cascade_to( :class, & block_instance )
296
+
297
+ proxy.parent_multiple_hook_controller_proxy.name.should == :after_include_subclass
298
+
299
+ proxy.proxies.each do |this_proxy|
300
+ this_proxy.contexts.should == [ :class, :module ]
301
+ this_hook_controller = this_proxy.parent_hook_controller
302
+ this_hook_controller.stack[ 0 ].module.should == nil
303
+ this_hook_controller.stack[ 0 ].owner.should == Instance
304
+ this_hook_controller.stack[ 0 ].action.should == nil
305
+ this_hook_controller.stack[ 0 ].context.should == [ :class, :module ]
306
+ this_hook_controller.stack[ 0 ].cascades.should == [ :class ]
307
+ this_hook_controller.stack[ 0 ].block.should == block_instance
308
+ end
309
+
310
+ end
311
+ end
312
+
313
+ ###############################
314
+ # before_extend_or_subclass #
315
+ # before_subclass_or_extend #
316
+ ###############################
317
+
318
+ it 'can create before-extend-or-subclass hooks' do
319
+ module ::Module::Cluster::Cluster::BeforeExtendSubclassMock
320
+
321
+ ::Module::Cluster::Cluster.instance_method( :before_extend_or_subclass ).should == ::Module::Cluster::Cluster.instance_method( :before_subclass_or_extend )
322
+
323
+ Instance = ::Module.new
324
+ cluster_instance = ::Module::Cluster::Cluster.new( Instance, :before_extend_subclass )
325
+
326
+ block_ran = false
327
+ block_instance = ::Proc.new do
328
+ block_ran = true
329
+ end
330
+
331
+ proxy = cluster_instance.before_extend_or_subclass( :class, :module ).cascade_to( :class, & block_instance )
332
+
333
+ proxy.parent_multiple_hook_controller_proxy.name.should == :before_extend_subclass
334
+
335
+ proxy.proxies.each do |this_proxy|
336
+ this_proxy.contexts.should == [ :class, :module ]
337
+ this_hook_controller = this_proxy.parent_hook_controller
338
+ this_hook_controller.stack[ 0 ].module.should == nil
339
+ this_hook_controller.stack[ 0 ].owner.should == Instance
340
+ this_hook_controller.stack[ 0 ].action.should == nil
341
+ this_hook_controller.stack[ 0 ].context.should == [ :class, :module ]
342
+ this_hook_controller.stack[ 0 ].cascades.should == [ :class ]
343
+ this_hook_controller.stack[ 0 ].block.should == block_instance
344
+ end
345
+
346
+ end
347
+ end
348
+
349
+ ##############################
350
+ # after_extend_or_subclass #
351
+ # after_subclass_or_extend #
352
+ ##############################
353
+
354
+ it 'can create after-extend-or-subclass hooks' do
355
+ module ::Module::Cluster::Cluster::AfterExtendSubclassMock
356
+
357
+ ::Module::Cluster::Cluster.instance_method( :after_extend_or_subclass ).should == ::Module::Cluster::Cluster.instance_method( :after_subclass_or_extend )
358
+
359
+ Instance = ::Module.new
360
+ cluster_instance = ::Module::Cluster::Cluster.new( Instance, :after_extend_subclass )
361
+
362
+ block_ran = false
363
+ block_instance = ::Proc.new do
364
+ block_ran = true
365
+ end
366
+
367
+ proxy = cluster_instance.after_extend_or_subclass( :class, :module ).cascade_to( :class, & block_instance )
368
+
369
+ proxy.parent_multiple_hook_controller_proxy.name.should == :after_extend_subclass
370
+
371
+ proxy.proxies.each do |this_proxy|
372
+ this_proxy.contexts.should == [ :class, :module ]
373
+ this_hook_controller = this_proxy.parent_hook_controller
374
+ this_hook_controller.stack[ 0 ].module.should == nil
375
+ this_hook_controller.stack[ 0 ].owner.should == Instance
376
+ this_hook_controller.stack[ 0 ].action.should == nil
377
+ this_hook_controller.stack[ 0 ].context.should == [ :class, :module ]
378
+ this_hook_controller.stack[ 0 ].cascades.should == [ :class ]
379
+ this_hook_controller.stack[ 0 ].block.should == block_instance
380
+ end
381
+
382
+ end
383
+ end
384
+
385
+ ##########################################
386
+ # before_include_or_extend_or_subclass #
387
+ # before_include_or_subclass_or_extend #
388
+ # before_extend_or_include_or_subclass #
389
+ # before_extend_or_subclass_or_include #
390
+ # before_subclass_or_include_or_extend #
391
+ # before_subclass_or_extend_or_include #
392
+ ##########################################
393
+
394
+ it 'can create before-include-or-extend-or-subclass hooks' do
395
+ module ::Module::Cluster::Cluster::BeforeIncludeExtendSubclassMock
396
+
397
+ ::Module::Cluster::Cluster.instance_method( :before_include_or_subclass_or_extend ).should == ::Module::Cluster::Cluster.instance_method( :before_include_or_extend_or_subclass )
398
+ ::Module::Cluster::Cluster.instance_method( :before_extend_or_include_or_subclass ).should == ::Module::Cluster::Cluster.instance_method( :before_include_or_extend_or_subclass )
399
+ ::Module::Cluster::Cluster.instance_method( :before_extend_or_subclass_or_include ).should == ::Module::Cluster::Cluster.instance_method( :before_include_or_extend_or_subclass )
400
+ ::Module::Cluster::Cluster.instance_method( :before_subclass_or_include_or_extend ).should == ::Module::Cluster::Cluster.instance_method( :before_include_or_extend_or_subclass )
401
+ ::Module::Cluster::Cluster.instance_method( :before_subclass_or_extend_or_include ).should == ::Module::Cluster::Cluster.instance_method( :before_include_or_extend_or_subclass )
402
+
403
+ Instance = ::Module.new
404
+ cluster_instance = ::Module::Cluster::Cluster.new( Instance, :before_include_extend_subclass )
405
+
406
+ block_ran = false
407
+ block_instance = ::Proc.new do
408
+ block_ran = true
409
+ end
410
+
411
+ proxy = cluster_instance.before_include_or_extend_or_subclass( :class, :module ).cascade_to( :class, & block_instance )
412
+
413
+ proxy.parent_multiple_hook_controller_proxy.name.should == :before_include_extend_subclass
414
+
415
+ proxy.proxies.each do |this_proxy|
416
+ this_proxy.contexts.should == [ :class, :module ]
417
+ this_hook_controller = this_proxy.parent_hook_controller
418
+ this_hook_controller.stack[ 0 ].module.should == nil
419
+ this_hook_controller.stack[ 0 ].owner.should == Instance
420
+ this_hook_controller.stack[ 0 ].action.should == nil
421
+ this_hook_controller.stack[ 0 ].context.should == [ :class, :module ]
422
+ this_hook_controller.stack[ 0 ].cascades.should == [ :class ]
423
+ this_hook_controller.stack[ 0 ].block.should == block_instance
424
+ end
425
+
426
+ end
427
+ end
428
+
429
+ #########################################
430
+ # after_include_or_extend_or_subclass #
431
+ # after_include_or_subclass_or_extend #
432
+ # after_extend_or_include_or_subclass #
433
+ # after_extend_or_subclass_or_include #
434
+ # after_subclass_or_include_or_extend #
435
+ # after_subclass_or_extend_or_include #
436
+ #########################################
437
+
438
+ it 'can create after-include-or-extend-or-subclass hooks' do
439
+ module ::Module::Cluster::Cluster::AfterIncludeExtendSubclassMock
440
+
441
+ ::Module::Cluster::Cluster.instance_method( :after_include_or_subclass_or_extend ).should == ::Module::Cluster::Cluster.instance_method( :after_include_or_extend_or_subclass )
442
+ ::Module::Cluster::Cluster.instance_method( :after_extend_or_include_or_subclass ).should == ::Module::Cluster::Cluster.instance_method( :after_include_or_extend_or_subclass )
443
+ ::Module::Cluster::Cluster.instance_method( :after_extend_or_subclass_or_include ).should == ::Module::Cluster::Cluster.instance_method( :after_include_or_extend_or_subclass )
444
+ ::Module::Cluster::Cluster.instance_method( :after_subclass_or_include_or_extend ).should == ::Module::Cluster::Cluster.instance_method( :after_include_or_extend_or_subclass )
445
+ ::Module::Cluster::Cluster.instance_method( :after_subclass_or_extend_or_include ).should == ::Module::Cluster::Cluster.instance_method( :after_include_or_extend_or_subclass )
446
+
447
+ Instance = ::Module.new
448
+ cluster_instance = ::Module::Cluster::Cluster.new( Instance, :after_include_extend_subclass )
449
+
450
+ block_ran = false
451
+ block_instance = ::Proc.new do
452
+ block_ran = true
453
+ end
454
+
455
+ proxy = cluster_instance.after_include_or_extend_or_subclass( :class, :module ).cascade_to( :class, & block_instance )
456
+
457
+ proxy.parent_multiple_hook_controller_proxy.name.should == :after_include_extend_subclass
458
+
459
+ proxy.proxies.each do |this_proxy|
460
+ this_proxy.contexts.should == [ :class, :module ]
461
+ this_hook_controller = this_proxy.parent_hook_controller
462
+ this_hook_controller.stack[ 0 ].module.should == nil
463
+ this_hook_controller.stack[ 0 ].owner.should == Instance
464
+ this_hook_controller.stack[ 0 ].action.should == nil
465
+ this_hook_controller.stack[ 0 ].context.should == [ :class, :module ]
466
+ this_hook_controller.stack[ 0 ].cascades.should == [ :class ]
467
+ this_hook_controller.stack[ 0 ].block.should == block_instance
468
+ end
469
+
470
+ end
471
+ end
472
+
473
+ end