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,26 @@
1
+
2
+ ###
3
+ # Exception raised when a module is provided for a before/after insert but module is not present in stack
4
+ # as specified.
5
+ #
6
+ class ::Module::Cluster::Exception::ModuleNotInStack < ::ArgumentError
7
+
8
+ ################
9
+ # initialize #
10
+ ################
11
+
12
+ ###
13
+ #
14
+ # @param hook_controller Hook Controller where module was not found.
15
+ #
16
+ # @param module_instance Module not found.
17
+ #
18
+ def initialize( hook_controller, module_instance )
19
+
20
+ message_string = 'Module ' + module_instance.to_s + ' not found in stack ' + hook_controller.name.to_s + '.'
21
+
22
+ super( message_string )
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,14 @@
1
+
2
+ ###
3
+ # @private
4
+ #
5
+ # Controls event hook stacks for a given Module or Class instance.
6
+ # Holds controllers for before and after include and extend and after subclass events.
7
+ # Controllers hold action stacks, which include/extend modules, perform block actions,
8
+ # or cascade actions to an inheriting instance.
9
+ #
10
+ class ::Module::Cluster::InstanceController
11
+
12
+ include ::Module::Cluster::InstanceController::InstanceControllerInterface
13
+
14
+ end
@@ -0,0 +1,33 @@
1
+
2
+ ###
3
+ # A Hook Controller manages a stack of actions for a given event hook (before/after include, extend or subclass).
4
+ # The action stack manages stack frames, each of which provides details for an action to be performed
5
+ # at event hook.
6
+ #
7
+ class ::Module::Cluster::InstanceController::HookController
8
+
9
+ #############
10
+ # extend! #
11
+ #############
12
+
13
+ ###
14
+ # Alias to original Module#extend method.
15
+ #
16
+ class << self
17
+ alias_method :extend!, :extend
18
+ end
19
+
20
+ ##############
21
+ # include! #
22
+ ##############
23
+
24
+ ###
25
+ # Alias to original Module#include method.
26
+ #
27
+ class << self
28
+ alias_method :include!, :include
29
+ end
30
+
31
+ include ::Module::Cluster::InstanceController::HookController::HookControllerInterface
32
+
33
+ end
@@ -0,0 +1,511 @@
1
+
2
+ ###
3
+ # An InstanceController uses an InstanceController::HookController::ChainProxy to chain commands
4
+ # that rely on chained state.
5
+ #
6
+ class ::Module::Cluster::InstanceController::HookController::ChainProxy
7
+
8
+ ################
9
+ # initialize #
10
+ ################
11
+
12
+ ###
13
+ # @private
14
+ #
15
+ # @param parent_hook_controller Hook Controller for which this Chain Proxy is operative.
16
+ #
17
+ def initialize( parent_hook_controller )
18
+
19
+ @parent_hook_controller = parent_hook_controller
20
+
21
+ @contexts = [ ]
22
+ @cascades_to = [ ]
23
+
24
+ @index = -1
25
+
26
+ end
27
+
28
+ #############
29
+ # include #
30
+ #############
31
+
32
+ ###
33
+ # Declare that modules should be included at event hook in the context specified this chained declaration.
34
+ #
35
+ # @overload include( module, .., & block )
36
+ #
37
+ # @param module Module to include at event hook in the context specified this chained declaration.
38
+ #
39
+ # @yield [hooked_instance] Block for event hook action.
40
+ # @yieldparam hooked_instance Instance for which event hook is occurring.
41
+ # Equivalent to parameter for #included and #extended.
42
+ #
43
+ # @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
44
+ #
45
+ def include( *modules, & block )
46
+
47
+ @parent_hook_controller.include_at_index( @index, @cluster_name, @contexts, @cascades_to, true, *modules, & block )
48
+
49
+ return self
50
+
51
+ end
52
+
53
+ ############
54
+ # extend #
55
+ ############
56
+
57
+ ###
58
+ # Declare that modules should be extended at event hook in the context specified this chained declaration.
59
+ #
60
+ # @overload extend( module, .., & block )
61
+ #
62
+ # @param module Module to extend at event hook in the context specified this chained declaration.
63
+ #
64
+ # @yield [hooked_instance] Block for event hook action.
65
+ # @yieldparam hooked_instance Instance for which event hook is occurring.
66
+ # Equivalent to parameter for #included and #extended.
67
+ #
68
+ # @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
69
+ #
70
+ def extend( *modules, & block )
71
+
72
+ @index = @parent_hook_controller.extend_at_index( @index,
73
+ @cluster_name,
74
+ @contexts,
75
+ @cascades_to,
76
+ true,
77
+ *modules,
78
+ & block )
79
+
80
+ return self
81
+
82
+ end
83
+
84
+ ########################
85
+ # include_and_extend #
86
+ ########################
87
+
88
+ ###
89
+ # Declare that modules should be included and extended at event hook in the context
90
+ # specified this chained declaration. See also #extend_and_include.
91
+ #
92
+ # @overload include_and_extend( module, .., & block )
93
+ #
94
+ # @param module Module to include and extend at event hook in the context specified this chained declaration.
95
+ #
96
+ # @yield [hooked_instance] Block for event hook action.
97
+ # @yieldparam hooked_instance Instance for which event hook is occurring.
98
+ # Equivalent to parameter for #included and #extended.
99
+ #
100
+ # @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
101
+ #
102
+ def include_and_extend( *modules, & block )
103
+
104
+ @index = @parent_hook_controller.include_and_extend_at_index( @index,
105
+ @cluster_name,
106
+ @contexts,
107
+ @cascades_to,
108
+ true,
109
+ *modules,
110
+ & block )
111
+
112
+ return self
113
+
114
+ end
115
+
116
+ ########################
117
+ # extend_and_include #
118
+ ########################
119
+
120
+ ###
121
+ # Declare that modules should be extended and included at event hook in the context
122
+ # specified this chained declaration. Order is reversed from #include_and_extend.
123
+ #
124
+ # @overload extend_and_include( module, .., & block )
125
+ #
126
+ # @param module Module to extend and include at event hook in the context specified this chained declaration.
127
+ #
128
+ # @yield [hooked_instance] Block for event hook action.
129
+ # @yieldparam hooked_instance Instance for which event hook is occurring.
130
+ # Equivalent to parameter for #included and #extended.
131
+ #
132
+ # @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
133
+ #
134
+ def extend_and_include( *modules, & block )
135
+
136
+ @index = @parent_hook_controller.extend_and_include_at_index( @index,
137
+ @cluster_name,
138
+ @contexts,
139
+ @cascades_to,
140
+ true,
141
+ *modules,
142
+ & block )
143
+
144
+ return self
145
+
146
+ end
147
+
148
+ ############
149
+ # action #
150
+ ############
151
+
152
+ ###
153
+ # Declare that action should be performed at event hook in the context
154
+ # specified this chained declaration.
155
+ #
156
+ # @yield [hooked_instance] Block for event hook action.
157
+ # @yieldparam hooked_instance Instance for which event hook is occurring.
158
+ # Equivalent to parameter for #included and #extended.
159
+ #
160
+ # @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
161
+ #
162
+ def action( & block )
163
+
164
+ @index = @parent_hook_controller.action_at_index( @index, @cluster_name, @contexts, @cascades_to, true, & block )
165
+
166
+ return self
167
+
168
+ end
169
+
170
+ ################
171
+ # cascade #
172
+ # cascade_to #
173
+ ################
174
+
175
+ ###
176
+ # Declare contexts to which declarations made from this declaration chain should cascade.
177
+ #
178
+ # @overload cascade( context, .., & block )
179
+ #
180
+ # @param context nil, :any, :class, :module, :subclass Contexts that should have event hooks cascaded into them.
181
+ #
182
+ # @yield [hooked_instance] Block for event hook action.
183
+ # @yieldparam hooked_instance Instance for which event hook is occurring.
184
+ # Equivalent to parameter for #included and #extended.
185
+ #
186
+ # @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
187
+ #
188
+ def cascade( *cascade_contexts, & block )
189
+
190
+ case cascade_contexts.count
191
+
192
+ when 0
193
+
194
+ @cascades_to.clear
195
+ @cascades_to.push( :any )
196
+
197
+ when 1
198
+
199
+ if cascade_contexts[ 0 ].nil?
200
+ @cascades_to.clear
201
+ else
202
+ @cascades_to.replace( cascade_contexts )
203
+ end
204
+
205
+ else
206
+
207
+ @cascades_to.replace( cascade_contexts )
208
+
209
+ end
210
+
211
+ if block_given?
212
+ action( & block )
213
+ end
214
+
215
+ return self
216
+
217
+ end
218
+
219
+ alias_method :cascade_to, :cascade
220
+
221
+ ###################
222
+ # before_extend #
223
+ ###################
224
+
225
+ ###
226
+ # Declare that chained actions should be inserted into the event stack prior to the location
227
+ # in the same event stack where provided module(s) are specified to be extended.
228
+ #
229
+ # @overload before_extend( module, .., & block )
230
+ #
231
+ # @param module Module that insert should be prior to.
232
+ #
233
+ # @yield [hooked_instance] Block for event hook action.
234
+ # @yieldparam hooked_instance Instance for which event hook is occurring.
235
+ # Equivalent to parameter for #included and #extended.
236
+ #
237
+ # @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
238
+ #
239
+ def before_extend( *modules )
240
+
241
+ @index = parent_hook_controller.lowest_index( :extend, *modules )
242
+
243
+ return self
244
+
245
+ end
246
+
247
+ ####################
248
+ # before_include #
249
+ ####################
250
+
251
+ ###
252
+ # Declare that chained actions should be inserted into the event stack prior to the location
253
+ # in the same event stack where provided module(s) are specified to be included.
254
+ #
255
+ # @overload before_include( module, .., & block )
256
+ #
257
+ # @param module Module that insert should be prior to.
258
+ #
259
+ # @yield [hooked_instance] Block for event hook action.
260
+ # @yieldparam hooked_instance Instance for which event hook is occurring.
261
+ # Equivalent to parameter for #included and #extended.
262
+ #
263
+ # @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
264
+ #
265
+ def before_include( *modules )
266
+
267
+ @index = parent_hook_controller.lowest_index( :include, *modules )
268
+
269
+ return self
270
+
271
+ end
272
+
273
+ ##############################
274
+ # before_include_or_extend #
275
+ # before_extend_or_include #
276
+ ##############################
277
+
278
+ ###
279
+ # Declare that chained actions should be inserted into the event stack prior to the location
280
+ # in the same event stack where provided module(s) are specified to be included or extended.
281
+ #
282
+ # @overload before_include_or_extend( module, .., & block )
283
+ #
284
+ # @param module Module that insert should be prior to.
285
+ #
286
+ # @yield [hooked_instance] Block for event hook action.
287
+ # @yieldparam hooked_instance Instance for which event hook is occurring.
288
+ # Equivalent to parameter for #included and #extended.
289
+ #
290
+ # @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
291
+ #
292
+ def before_include_or_extend( *modules )
293
+
294
+ @index = parent_hook_controller.lowest_index( :include_or_extend, *modules )
295
+
296
+ return self
297
+
298
+ end
299
+
300
+ alias_method :before_extend_or_include, :before_include_or_extend
301
+
302
+ ###################
303
+ # after_include #
304
+ ###################
305
+
306
+ ###
307
+ # Declare that chained actions should be inserted into the event stack after the location
308
+ # in the same event stack where provided module(s) are specified to be included.
309
+ #
310
+ # @overload before_include( module, .., & block )
311
+ #
312
+ # @param module Module that insert should be after.
313
+ #
314
+ # @yield [hooked_instance] Block for event hook action.
315
+ # @yieldparam hooked_instance Instance for which event hook is occurring.
316
+ # Equivalent to parameter for #included and #extended.
317
+ #
318
+ # @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
319
+ #
320
+ def after_include( *modules )
321
+
322
+ @index = parent_hook_controller.highest_index( :include, *modules ) + 1
323
+
324
+ return self
325
+
326
+ end
327
+
328
+ ##################
329
+ # after_extend #
330
+ ##################
331
+
332
+ ###
333
+ # Declare that chained actions should be inserted into the event stack after the location
334
+ # in the same event stack where provided module(s) are specified to be extended.
335
+ #
336
+ # @overload before_extend( module, .., & block )
337
+ #
338
+ # @param module Module that insert should be after.
339
+ #
340
+ # @yield [hooked_instance] Block for event hook action.
341
+ # @yieldparam hooked_instance Instance for which event hook is occurring.
342
+ # Equivalent to parameter for #included and #extended.
343
+ #
344
+ # @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
345
+ #
346
+ def after_extend( *modules )
347
+
348
+ @index = parent_hook_controller.highest_index( :extend, *modules ) + 1
349
+
350
+ return self
351
+
352
+ end
353
+
354
+ #############################
355
+ # after_include_or_extend #
356
+ # after_extend_or_include #
357
+ #############################
358
+
359
+ ###
360
+ # Declare that chained actions should be inserted into the event stack after the location
361
+ # in the same event stack where provided module(s) are specified to be included or extended.
362
+ #
363
+ # @overload before_include_or_extend( module, .., & block )
364
+ #
365
+ # @param module Module that insert should be after.
366
+ #
367
+ # @yield [hooked_instance] Block for event hook action.
368
+ # @yieldparam hooked_instance Instance for which event hook is occurring.
369
+ # Equivalent to parameter for #included and #extended.
370
+ #
371
+ # @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
372
+ #
373
+ def after_include_or_extend( *modules )
374
+
375
+ @index = parent_hook_controller.highest_index( :include_or_extend, *modules ) + 1
376
+
377
+ return self
378
+
379
+ end
380
+
381
+ alias_method :after_extend_or_include, :after_include_or_extend
382
+
383
+ #############
384
+ # context #
385
+ #############
386
+
387
+ ###
388
+ # Set context for matching instance to determine whether to perform chained actions in stack.
389
+ #
390
+ # @overload context( context, .. )
391
+ #
392
+ # @param context nil, :any, :class, :module, :subclass Contexts that should have event hooks cascaded into them.
393
+ #
394
+ # @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
395
+ #
396
+ def context( *contexts )
397
+
398
+ @contexts.replace( contexts )
399
+
400
+ return self
401
+
402
+ end
403
+
404
+ ######################################################################################################################
405
+ # private ##########################################################################################################
406
+ ######################################################################################################################
407
+
408
+ ###
409
+ # These methods are not actually in private space but are internal methods for inter-object
410
+ # communications. They aren't intended for public interfacing.
411
+ #
412
+
413
+ ############################
414
+ # parent_hook_controller #
415
+ ############################
416
+
417
+ ###
418
+ # @private
419
+ #
420
+ # Hook controller for which this instance is operative as a chaining proxy.
421
+ #
422
+ attr_reader :parent_hook_controller
423
+
424
+ #################
425
+ # reset_state #
426
+ #################
427
+
428
+ ###
429
+ # @private
430
+ #
431
+ # Reset internal state data so that proxy can be re-used for chaining in a new context.
432
+ #
433
+ # @return [Module::Cluster::InstanceController::ChainProxy] Self.
434
+ #
435
+ def reset_state
436
+
437
+ @cluster_name = nil
438
+ @index = -1
439
+
440
+ @contexts.clear
441
+ @cascades_to.clear
442
+
443
+ return self
444
+
445
+ end
446
+
447
+ ##################
448
+ # cluster_name #
449
+ ##################
450
+
451
+ ###
452
+ # @private
453
+ #
454
+ # Set cluster name for which chained actions will be inserted in stack.
455
+ #
456
+ # @return [Module::Cluster::InstanceController::ChainProxy] Self.
457
+ #
458
+ def cluster_name( cluster_name )
459
+
460
+ @cluster_name = cluster_name
461
+
462
+ return self
463
+
464
+ end
465
+
466
+ ###########
467
+ # index #
468
+ ###########
469
+
470
+ ###
471
+ # @private
472
+ #
473
+ # Set index where chained actions will be inserted in stack.
474
+ #
475
+ # @return [Module::Cluster::InstanceController::ChainProxy] Self.
476
+ #
477
+ def index( index )
478
+
479
+ @index = index
480
+
481
+ return self
482
+
483
+ end
484
+
485
+ ##############
486
+ # contexts #
487
+ ##############
488
+
489
+ ###
490
+ # @private
491
+ #
492
+ # Contexts (nil, :module, :class, :subclass, :instance) for which this instance is operative as a chain proxy.
493
+ #
494
+ # @return [Array<Symbol,nil>] Contexts for which this Chain Proxy instance is operative.
495
+ #
496
+ attr_reader :contexts
497
+
498
+ #################
499
+ # cascades_to #
500
+ #################
501
+
502
+ ###
503
+ # @private
504
+ #
505
+ # Contexts (nil, :module, :class, :subclass, :instance) for which this instance cascades.
506
+ #
507
+ # @return [Array<Symbol,nil>] Contexts for which this Chain Proxy instance cascades.
508
+ #
509
+ attr_reader :cascades_to
510
+
511
+ end