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.
- data/README.md +127 -337
- data/lib/module-cluster.rb +1 -153
- data/lib/module/cluster.rb +341 -0
- data/lib/module/cluster/class_support.rb +22 -0
- data/lib/module/cluster/cluster.rb +10 -0
- data/lib/module/cluster/cluster/cluster_interface.rb +550 -0
- data/lib/module/cluster/exception/module_not_in_stack.rb +26 -0
- data/lib/module/cluster/instance_controller.rb +14 -0
- data/lib/module/cluster/instance_controller/hook_controller.rb +33 -0
- data/lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb +511 -0
- data/lib/module/cluster/instance_controller/hook_controller/hook_controller_interface.rb +830 -0
- data/lib/module/cluster/instance_controller/instance_controller_interface.rb +269 -0
- data/lib/module/cluster/instance_controller/multiple_hook_controller_proxy.rb +359 -0
- data/lib/module/cluster/instance_controller/multiple_hook_controller_proxy/chain_proxy.rb +442 -0
- data/lib/module/cluster/module_support.rb +67 -0
- data/lib/module/namespaces.rb +13 -0
- data/lib/module/requires.rb +32 -0
- data/spec/module/cluster/cluster_spec.rb +473 -0
- data/spec/module/cluster/instance_controller/hook_controller_spec.rb +922 -0
- data/spec/module/cluster/instance_controller/multiple_hook_controller_proxy_spec.rb +1240 -0
- data/spec/module/cluster_spec.rb +1794 -0
- metadata +27 -98
- data/README.rdoc +0 -395
- data/lib/module-cluster/ModuleCluster.rb +0 -9
- data/lib/module-cluster/ModuleCluster/Define.rb +0 -12
- data/lib/module-cluster/ModuleCluster/Define/Block.rb +0 -9
- data/lib/module-cluster/ModuleCluster/Define/Block/CascadingClass.rb +0 -83
- data/lib/module-cluster/ModuleCluster/Define/Block/CascadingClassOrModule.rb +0 -70
- data/lib/module-cluster/ModuleCluster/Define/Block/CascadingModule.rb +0 -79
- data/lib/module-cluster/ModuleCluster/Define/Block/CascadingModuleOrSubclass.rb +0 -21
- data/lib/module-cluster/ModuleCluster/Define/Block/Class.rb +0 -77
- data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrInstance.rb +0 -78
- data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModule.rb +0 -78
- data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrInstance.rb +0 -78
- data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrSubclass.rb +0 -36
- data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrSubclass.rb +0 -29
- data/lib/module-cluster/ModuleCluster/Define/Block/Instance.rb +0 -45
- data/lib/module-cluster/ModuleCluster/Define/Block/Module.rb +0 -77
- data/lib/module-cluster/ModuleCluster/Define/Block/ModuleOrInstance.rb +0 -78
- data/lib/module-cluster/ModuleCluster/Define/Block/ModuleOrSubclass.rb +0 -29
- data/lib/module-cluster/ModuleCluster/Define/Block/Subclass.rb +0 -56
- data/lib/module-cluster/ModuleCluster/Define/ClassCluster.rb +0 -193
- data/lib/module-cluster/ModuleCluster/Define/ClassOrInstanceCluster.rb +0 -128
- data/lib/module-cluster/ModuleCluster/Define/Cluster.rb +0 -181
- data/lib/module-cluster/ModuleCluster/Define/ClusterCascades.rb +0 -185
- data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToClass.rb +0 -181
- data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToModule.rb +0 -181
- data/lib/module-cluster/ModuleCluster/Define/Deprecated.rb +0 -40
- data/lib/module-cluster/ModuleCluster/Define/InstanceCluster.rb +0 -45
- data/lib/module-cluster/ModuleCluster/Define/ModuleCluster.rb +0 -193
- data/lib/module-cluster/ModuleCluster/Define/ModuleOrClassCluster.rb +0 -209
- data/lib/module-cluster/ModuleCluster/Define/ModuleOrInstanceCluster.rb +0 -128
- data/lib/module-cluster/ModuleCluster/Define/Status.rb +0 -106
- data/lib/module-cluster/ModuleCluster/Suspend.rb +0 -7
- data/lib/module-cluster/ModuleCluster/Suspend/Hooks.rb +0 -315
- data/lib/module-cluster/ModuleCluster/Suspend/WithoutHooks.rb +0 -153
- data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures.rb +0 -77
- data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/ClusterStack.rb +0 -44
- data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/PerformCascades.rb +0 -292
- data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/Subclass.rb +0 -24
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack.rb +0 -12
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block.rb +0 -9
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Class.rb +0 -36
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Inherited.rb +0 -20
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Instance.rb +0 -20
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Module.rb +0 -36
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Set.rb +0 -6
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Extends.rb +0 -140
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Includes.rb +0 -110
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsExtends.rb +0 -140
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsIncludes.rb +0 -110
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Set.rb +0 -35
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Set/MultiSetProxy.rb +0 -359
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Status.rb +0 -55
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Suspend.rb +0 -199
- data/lib/module-cluster/_private_/ModuleCluster/ExtendForCascade.rb +0 -34
- data/spec/ModuleCluster/Define/Block/CascadingClassOrModule_spec.rb +0 -285
- data/spec/ModuleCluster/Define/Block/CascadingClass_spec.rb +0 -254
- data/spec/ModuleCluster/Define/Block/CascadingModuleOrSubclass_spec.rb +0 -56
- data/spec/ModuleCluster/Define/Block/CascadingModule_spec.rb +0 -278
- data/spec/ModuleCluster/Define/Block/ClassOrInstance_spec.rb +0 -230
- data/spec/ModuleCluster/Define/Block/ClassOrModuleOrInstance_spec.rb +0 -238
- data/spec/ModuleCluster/Define/Block/ClassOrModuleOrSubclass_spec.rb +0 -54
- data/spec/ModuleCluster/Define/Block/ClassOrModule_spec.rb +0 -231
- data/spec/ModuleCluster/Define/Block/ClassOrSubclass_spec.rb +0 -54
- data/spec/ModuleCluster/Define/Block/Class_spec.rb +0 -224
- data/spec/ModuleCluster/Define/Block/Instance_spec.rb +0 -78
- data/spec/ModuleCluster/Define/Block/ModuleOrInstance_spec.rb +0 -54
- data/spec/ModuleCluster/Define/Block/ModuleOrSubclass_spec.rb +0 -51
- data/spec/ModuleCluster/Define/Block/Module_spec.rb +0 -230
- data/spec/ModuleCluster/Define/Block/Subclass_spec.rb +0 -73
- data/spec/ModuleCluster/Define/Block_spec.rb +0 -18
- data/spec/ModuleCluster/Define/ClassCluster_spec.rb +0 -728
- data/spec/ModuleCluster/Define/ClassOrInstanceCluster_spec.rb +0 -576
- data/spec/ModuleCluster/Define/ClusterCascadesToClass_spec.rb +0 -659
- data/spec/ModuleCluster/Define/ClusterCascadesToModule_spec.rb +0 -678
- data/spec/ModuleCluster/Define/ClusterCascades_spec.rb +0 -644
- data/spec/ModuleCluster/Define/Cluster_spec.rb +0 -708
- data/spec/ModuleCluster/Define/InstanceCluster_spec.rb +0 -102
- data/spec/ModuleCluster/Define/ModuleCluster_spec.rb +0 -728
- data/spec/ModuleCluster/Define/ModuleOrClassCluster_spec.rb +0 -728
- data/spec/ModuleCluster/Define/ModuleOrInstanceCluster_spec.rb +0 -576
- data/spec/ModuleCluster/Suspend/Hooks_spec.rb +0 -573
- data/spec/ModuleCluster/Suspend/WithoutHooks_spec.rb +0 -559
- data/spec/ModuleCluster_spec.rb +0 -15
- data/spec/_private_/ModuleCluster/CascadeFeatures/PerformCascades_spec.rb +0 -386
- data/spec/_private_/ModuleCluster/ClusterStack/Set/MultiSetProxy_spec.rb +0 -419
- data/spec/_private_/ModuleCluster/ClusterStack/Suspend_spec.rb +0 -242
@@ -0,0 +1,442 @@
|
|
1
|
+
|
2
|
+
###
|
3
|
+
# A MultipleHookControllerProxy uses a MultipleHookControllerProxy::ChainProxy
|
4
|
+
# to chain commands that rely on chained state.
|
5
|
+
#
|
6
|
+
class ::Module::Cluster::InstanceController::MultipleHookControllerProxy::ChainProxy
|
7
|
+
|
8
|
+
################
|
9
|
+
# initialize #
|
10
|
+
################
|
11
|
+
|
12
|
+
###
|
13
|
+
# @private
|
14
|
+
#
|
15
|
+
# @param parent_multiple_hook_controller_proxy Multiple Hook Controller Proxy for which this Chain Proxy is operative.
|
16
|
+
#
|
17
|
+
def initialize( parent_multiple_hook_controller_proxy )
|
18
|
+
|
19
|
+
@parent_multiple_hook_controller_proxy = parent_multiple_hook_controller_proxy
|
20
|
+
|
21
|
+
@proxies = @parent_multiple_hook_controller_proxy.hook_controllers.collect( & :chain_proxy )
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
#############
|
26
|
+
# include #
|
27
|
+
#############
|
28
|
+
|
29
|
+
###
|
30
|
+
# Declare that modules should be included at event hook in the context specified this chained declaration.
|
31
|
+
#
|
32
|
+
# @overload include( module, ..., & block )
|
33
|
+
#
|
34
|
+
# @param module Module to include at event hook in the context specified this chained declaration.
|
35
|
+
#
|
36
|
+
# @yield [hooked_instance] Block for event hook action.
|
37
|
+
# @yieldparam hooked_instance Instance for which event hook is occurring.
|
38
|
+
# Equivalent to parameter for #included and #extended.
|
39
|
+
#
|
40
|
+
# @return [Module::Cluster::InstanceController::MultipleHookControllerProxy::ChainProxy] self
|
41
|
+
#
|
42
|
+
def include( *modules )
|
43
|
+
|
44
|
+
@proxies.each do |this_hook_controller_chain_proxy|
|
45
|
+
this_hook_controller_chain_proxy.include( *modules )
|
46
|
+
end
|
47
|
+
|
48
|
+
return self
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
############
|
53
|
+
# extend #
|
54
|
+
############
|
55
|
+
|
56
|
+
###
|
57
|
+
# Declare that modules should be extended at event hook in the context specified this chained declaration.
|
58
|
+
#
|
59
|
+
# @overload extend( module, ..., & block )
|
60
|
+
#
|
61
|
+
# @param module Module to extend at event hook in the context specified this chained declaration.
|
62
|
+
#
|
63
|
+
# @yield [hooked_instance] Block for event hook action.
|
64
|
+
# @yieldparam hooked_instance Instance for which event hook is occurring.
|
65
|
+
# Equivalent to parameter for #included and #extended.
|
66
|
+
#
|
67
|
+
# @return [Module::Cluster::InstanceController::MultipleHookControllerProxy::ChainProxy] self
|
68
|
+
#
|
69
|
+
def extend( *modules )
|
70
|
+
|
71
|
+
@proxies.each do |this_hook_controller_chain_proxy|
|
72
|
+
this_hook_controller_chain_proxy.extend( *modules )
|
73
|
+
end
|
74
|
+
|
75
|
+
return self
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
########################
|
80
|
+
# include_and_extend #
|
81
|
+
########################
|
82
|
+
|
83
|
+
###
|
84
|
+
# Declare that modules should be included and extended at event hook in the context
|
85
|
+
# specified this chained declaration. See also #extend_and_include.
|
86
|
+
#
|
87
|
+
# @overload include_and_extend( module, ..., & block )
|
88
|
+
#
|
89
|
+
# @param module Module to include and extend at event hook in the context specified this chained declaration.
|
90
|
+
#
|
91
|
+
# @yield [hooked_instance] Block for event hook action.
|
92
|
+
# @yieldparam hooked_instance Instance for which event hook is occurring.
|
93
|
+
# Equivalent to parameter for #included and #extended.
|
94
|
+
#
|
95
|
+
# @return [Module::Cluster::InstanceController::MultipleHookControllerProxy::ChainProxy] self
|
96
|
+
#
|
97
|
+
def include_and_extend( *modules )
|
98
|
+
|
99
|
+
@proxies.each do |this_hook_controller_chain_proxy|
|
100
|
+
this_hook_controller_chain_proxy.include_and_extend( *modules )
|
101
|
+
end
|
102
|
+
|
103
|
+
return self
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
########################
|
108
|
+
# extend_and_include #
|
109
|
+
########################
|
110
|
+
|
111
|
+
###
|
112
|
+
# Declare that modules should be extended and included at event hook in the context
|
113
|
+
# specified this chained declaration. Order is reversed from #include_and_extend.
|
114
|
+
#
|
115
|
+
# @overload extend_and_include( module, ..., & block )
|
116
|
+
#
|
117
|
+
# @param module Module to extend and include at event hook in the context specified this chained declaration.
|
118
|
+
#
|
119
|
+
# @yield [hooked_instance] Block for event hook action.
|
120
|
+
# @yieldparam hooked_instance Instance for which event hook is occurring.
|
121
|
+
# Equivalent to parameter for #included and #extended.
|
122
|
+
#
|
123
|
+
# @return [Module::Cluster::InstanceController::MultipleHookControllerProxy::ChainProxy] self
|
124
|
+
#
|
125
|
+
def extend_and_include( *modules )
|
126
|
+
|
127
|
+
@proxies.each do |this_hook_controller_chain_proxy|
|
128
|
+
this_hook_controller_chain_proxy.extend_and_include( *modules )
|
129
|
+
end
|
130
|
+
|
131
|
+
return self
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
############
|
136
|
+
# action #
|
137
|
+
############
|
138
|
+
|
139
|
+
###
|
140
|
+
# Declare that action should be performed at event hook in the context
|
141
|
+
# specified this chained declaration.
|
142
|
+
#
|
143
|
+
# @yield [hooked_instance] Block for event hook action.
|
144
|
+
# @yieldparam hooked_instance Instance for which event hook is occurring.
|
145
|
+
# Equivalent to parameter for #included and #extended.
|
146
|
+
#
|
147
|
+
# @return [Module::Cluster::InstanceController::MultipleHookControllerProxy::ChainProxy] self
|
148
|
+
#
|
149
|
+
def action( & block )
|
150
|
+
|
151
|
+
@proxies.each do |this_hook_controller_chain_proxy|
|
152
|
+
this_hook_controller_chain_proxy.action( & block )
|
153
|
+
end
|
154
|
+
|
155
|
+
return self
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
################
|
160
|
+
# cascade #
|
161
|
+
# cascade_to #
|
162
|
+
################
|
163
|
+
|
164
|
+
###
|
165
|
+
# Declare contexts to which declarations made from this declaration chain should cascade.
|
166
|
+
#
|
167
|
+
# @overload cascade( context, ..., & block )
|
168
|
+
#
|
169
|
+
# @param context nil, :any, :class, :module, :subclass Contexts that should have event hooks cascaded into them.
|
170
|
+
#
|
171
|
+
# @yield [hooked_instance] Block for event hook action.
|
172
|
+
# @yieldparam hooked_instance Instance for which event hook is occurring.
|
173
|
+
# Equivalent to parameter for #included and #extended.
|
174
|
+
#
|
175
|
+
# @return [Module::Cluster::InstanceController::MultipleHookControllerProxy::ChainProxy] self
|
176
|
+
#
|
177
|
+
def cascade( *cascade_contexts, & block )
|
178
|
+
|
179
|
+
@proxies.each do |this_hook_controller_chain_proxy|
|
180
|
+
this_hook_controller_chain_proxy.cascade( *cascade_contexts, & block )
|
181
|
+
end
|
182
|
+
|
183
|
+
return self
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
alias_method :cascade_to, :cascade
|
188
|
+
|
189
|
+
###################
|
190
|
+
# before_extend #
|
191
|
+
###################
|
192
|
+
|
193
|
+
###
|
194
|
+
# Declare that chained actions should be inserted into the event stack prior to the location
|
195
|
+
# in the same event stack where provided module(s) are specified to be extended.
|
196
|
+
#
|
197
|
+
# @overload before_extend( module, ..., & block )
|
198
|
+
#
|
199
|
+
# @param module Module that insert should be prior to.
|
200
|
+
#
|
201
|
+
# @yield [hooked_instance] Block for event hook action.
|
202
|
+
# @yieldparam hooked_instance Instance for which event hook is occurring.
|
203
|
+
# Equivalent to parameter for #included and #extended.
|
204
|
+
#
|
205
|
+
# @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
|
206
|
+
#
|
207
|
+
def before_extend( *modules )
|
208
|
+
|
209
|
+
@proxies.each do |this_hook_controller_chain_proxy|
|
210
|
+
this_hook_controller_chain_proxy.before_extend( *modules )
|
211
|
+
end
|
212
|
+
|
213
|
+
return self
|
214
|
+
|
215
|
+
end
|
216
|
+
|
217
|
+
####################
|
218
|
+
# before_include #
|
219
|
+
####################
|
220
|
+
|
221
|
+
###
|
222
|
+
# Declare that chained actions should be inserted into the event stack prior to the location
|
223
|
+
# in the same event stack where provided module(s) are specified to be included.
|
224
|
+
#
|
225
|
+
# @overload before_include( module, ..., & block )
|
226
|
+
#
|
227
|
+
# @param module Module that insert should be prior to.
|
228
|
+
#
|
229
|
+
# @yield [hooked_instance] Block for event hook action.
|
230
|
+
# @yieldparam hooked_instance Instance for which event hook is occurring.
|
231
|
+
# Equivalent to parameter for #included and #extended.
|
232
|
+
#
|
233
|
+
# @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
|
234
|
+
#
|
235
|
+
def before_include( *modules )
|
236
|
+
|
237
|
+
@proxies.each do |this_hook_controller_chain_proxy|
|
238
|
+
this_hook_controller_chain_proxy.before_include( *modules )
|
239
|
+
end
|
240
|
+
|
241
|
+
return self
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
##############################
|
246
|
+
# before_include_or_extend #
|
247
|
+
# before_extend_or_include #
|
248
|
+
##############################
|
249
|
+
|
250
|
+
###
|
251
|
+
# Declare that chained actions should be inserted into the event stack prior to the location
|
252
|
+
# in the same event stack where provided module(s) are specified to be included or extended.
|
253
|
+
#
|
254
|
+
# @overload before_include_or_extend( module, ..., & block )
|
255
|
+
#
|
256
|
+
# @param module Module that insert should be prior to.
|
257
|
+
#
|
258
|
+
# @yield [hooked_instance] Block for event hook action.
|
259
|
+
# @yieldparam hooked_instance Instance for which event hook is occurring.
|
260
|
+
# Equivalent to parameter for #included and #extended.
|
261
|
+
#
|
262
|
+
# @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
|
263
|
+
#
|
264
|
+
def before_include_or_extend( *modules )
|
265
|
+
|
266
|
+
@proxies.each do |this_hook_controller_chain_proxy|
|
267
|
+
this_hook_controller_chain_proxy.before_include_or_extend( *modules )
|
268
|
+
end
|
269
|
+
|
270
|
+
return self
|
271
|
+
|
272
|
+
end
|
273
|
+
|
274
|
+
alias_method :before_extend_or_include, :before_include_or_extend
|
275
|
+
|
276
|
+
###################
|
277
|
+
# after_include #
|
278
|
+
###################
|
279
|
+
|
280
|
+
###
|
281
|
+
# Declare that chained actions should be inserted into the event stack after the location
|
282
|
+
# in the same event stack where provided module(s) are specified to be included.
|
283
|
+
#
|
284
|
+
# @overload before_include( module, ..., & block )
|
285
|
+
#
|
286
|
+
# @param module Module that insert should be after.
|
287
|
+
#
|
288
|
+
# @yield [hooked_instance] Block for event hook action.
|
289
|
+
# @yieldparam hooked_instance Instance for which event hook is occurring.
|
290
|
+
# Equivalent to parameter for #included and #extended.
|
291
|
+
#
|
292
|
+
# @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
|
293
|
+
#
|
294
|
+
def after_include( *modules )
|
295
|
+
|
296
|
+
@proxies.each do |this_hook_controller_chain_proxy|
|
297
|
+
this_hook_controller_chain_proxy.after_include( *modules )
|
298
|
+
end
|
299
|
+
|
300
|
+
return self
|
301
|
+
|
302
|
+
end
|
303
|
+
|
304
|
+
##################
|
305
|
+
# after_extend #
|
306
|
+
##################
|
307
|
+
|
308
|
+
###
|
309
|
+
# Declare that chained actions should be inserted into the event stack after the location
|
310
|
+
# in the same event stack where provided module(s) are specified to be extended.
|
311
|
+
#
|
312
|
+
# @overload before_extend( module, ..., & block )
|
313
|
+
#
|
314
|
+
# @param module Module that insert should be after.
|
315
|
+
#
|
316
|
+
# @yield [hooked_instance] Block for event hook action.
|
317
|
+
# @yieldparam hooked_instance Instance for which event hook is occurring.
|
318
|
+
# Equivalent to parameter for #included and #extended.
|
319
|
+
#
|
320
|
+
# @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
|
321
|
+
#
|
322
|
+
def after_extend( *modules )
|
323
|
+
|
324
|
+
@proxies.each do |this_hook_controller_chain_proxy|
|
325
|
+
this_hook_controller_chain_proxy.after_extend( *modules )
|
326
|
+
end
|
327
|
+
|
328
|
+
return self
|
329
|
+
|
330
|
+
end
|
331
|
+
|
332
|
+
#############################
|
333
|
+
# after_include_or_extend #
|
334
|
+
# after_extend_or_include #
|
335
|
+
#############################
|
336
|
+
|
337
|
+
###
|
338
|
+
# Declare that chained actions should be inserted into the event stack after the location
|
339
|
+
# in the same event stack where provided module(s) are specified to be included or extended.
|
340
|
+
#
|
341
|
+
# @overload before_include_or_extend( module, ..., & block )
|
342
|
+
#
|
343
|
+
# @param module Module that insert should be after.
|
344
|
+
#
|
345
|
+
# @yield [hooked_instance] Block for event hook action.
|
346
|
+
# @yieldparam hooked_instance Instance for which event hook is occurring.
|
347
|
+
# Equivalent to parameter for #included and #extended.
|
348
|
+
#
|
349
|
+
# @return [Module::Cluster::InstanceController::HookController::ChainProxy] Self.
|
350
|
+
#
|
351
|
+
def after_include_or_extend( *modules )
|
352
|
+
|
353
|
+
@proxies.each do |this_hook_controller_chain_proxy|
|
354
|
+
this_hook_controller_chain_proxy.after_include_or_extend( *modules )
|
355
|
+
end
|
356
|
+
|
357
|
+
return self
|
358
|
+
|
359
|
+
end
|
360
|
+
|
361
|
+
alias_method :after_extend_or_include, :after_include_or_extend
|
362
|
+
|
363
|
+
#############
|
364
|
+
# context #
|
365
|
+
#############
|
366
|
+
|
367
|
+
###
|
368
|
+
# Set index where chained actions will be inserted in stack.
|
369
|
+
#
|
370
|
+
# @overload context( context, ... )
|
371
|
+
#
|
372
|
+
# @param context nil, :any, :class, :module, :subclass Contexts that should have event hooks cascaded into them.
|
373
|
+
#
|
374
|
+
# @return [Module::Cluster::InstanceController::MultipleHookControllerProxy::ChainProxy] Self.
|
375
|
+
#
|
376
|
+
def context( *contexts )
|
377
|
+
|
378
|
+
@proxies.each do |this_hook_controller_chain_proxy|
|
379
|
+
this_hook_controller_chain_proxy.context( *contexts )
|
380
|
+
end
|
381
|
+
|
382
|
+
return self
|
383
|
+
|
384
|
+
end
|
385
|
+
|
386
|
+
######################################################################################################################
|
387
|
+
# private ##########################################################################################################
|
388
|
+
######################################################################################################################
|
389
|
+
|
390
|
+
###
|
391
|
+
# These methods are not actually in private space but are internal methods for inter-object
|
392
|
+
# communications. They aren't intended for public interfacing.
|
393
|
+
#
|
394
|
+
|
395
|
+
###########################################
|
396
|
+
# parent_multiple_hook_controller_proxy #
|
397
|
+
###########################################
|
398
|
+
|
399
|
+
###
|
400
|
+
# @private
|
401
|
+
#
|
402
|
+
# @!attribute [reader] Multiple Hook Controller Proxy for which this instance is operative as a chaining proxy
|
403
|
+
#
|
404
|
+
# @return [Module::Cluster::InstanceController::MultipleHookControllerProxy] Parent Multiple Hook Controller Proxy.
|
405
|
+
#
|
406
|
+
attr_reader :parent_multiple_hook_controller_proxy
|
407
|
+
|
408
|
+
#############
|
409
|
+
# proxies #
|
410
|
+
#############
|
411
|
+
|
412
|
+
###
|
413
|
+
# @private
|
414
|
+
#
|
415
|
+
# @!attribute [reader] Proxies for which this instance is operative as a chaining proxy.
|
416
|
+
#
|
417
|
+
# @return [Array<Module::Cluster::InstanceController::HookController::ChainProxy>]
|
418
|
+
#
|
419
|
+
attr_reader :proxies
|
420
|
+
|
421
|
+
##################
|
422
|
+
# cluster_name #
|
423
|
+
##################
|
424
|
+
|
425
|
+
###
|
426
|
+
# @private
|
427
|
+
#
|
428
|
+
# Set cluster name for which chained actions will be inserted in stack.
|
429
|
+
#
|
430
|
+
# @return [Module::Cluster::InstanceController::MultipleHookControllerProxy::ChainProxy] Self.
|
431
|
+
#
|
432
|
+
def cluster_name( cluster_name )
|
433
|
+
|
434
|
+
@proxies.each do |this_hook_controller_chain_proxy|
|
435
|
+
this_hook_controller_chain_proxy.cluster_name( cluster_name )
|
436
|
+
end
|
437
|
+
|
438
|
+
return self
|
439
|
+
|
440
|
+
end
|
441
|
+
|
442
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
|
2
|
+
###
|
3
|
+
# Provides #append_features, #included, #extend_object, #extended support for {::Module::Cluster Module::Cluster}.
|
4
|
+
#
|
5
|
+
module ::Module::Cluster::ModuleSupport
|
6
|
+
|
7
|
+
#####################
|
8
|
+
# append_features #
|
9
|
+
#####################
|
10
|
+
|
11
|
+
###
|
12
|
+
# Ensures {::Module::Cluster Module::Cluster} before_include hooks occur at time of include.
|
13
|
+
#
|
14
|
+
def append_features( hooked_instance )
|
15
|
+
|
16
|
+
super if defined?( super )
|
17
|
+
|
18
|
+
::Module::Cluster.hook_cluster_events( self, hooked_instance, :before_include )
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
##############
|
23
|
+
# included #
|
24
|
+
##############
|
25
|
+
|
26
|
+
###
|
27
|
+
# Ensures {::Module::Cluster Module::Cluster} after_include hooks occur at time of include.
|
28
|
+
#
|
29
|
+
def included( hooked_instance )
|
30
|
+
|
31
|
+
super if defined?( super )
|
32
|
+
|
33
|
+
::Module::Cluster.hook_cluster_events( self, hooked_instance, :after_include )
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
###################
|
38
|
+
# extend_object #
|
39
|
+
###################
|
40
|
+
|
41
|
+
###
|
42
|
+
# Ensures {::Module::Cluster Module::Cluster} before_extend hooks occur at time of extend.
|
43
|
+
#
|
44
|
+
def extend_object( hooked_instance )
|
45
|
+
|
46
|
+
super if defined?( super )
|
47
|
+
|
48
|
+
::Module::Cluster.hook_cluster_events( self, hooked_instance, :before_extend )
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
##############
|
53
|
+
# extended #
|
54
|
+
##############
|
55
|
+
|
56
|
+
###
|
57
|
+
# Ensures {::Module::Cluster Module::Cluster} after_extend hooks occur at time of extend.
|
58
|
+
#
|
59
|
+
def extended( hooked_instance )
|
60
|
+
|
61
|
+
super if defined?( super )
|
62
|
+
|
63
|
+
::Module::Cluster.hook_cluster_events( self, hooked_instance, :after_extend )
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|