module-cluster 1.4.5 → 1.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,13 @@
|
|
1
1
|
|
2
2
|
module ::ModuleCluster::CascadeFeatures::PerformCascades
|
3
3
|
|
4
|
+
$this_time = 0
|
4
5
|
######################
|
5
6
|
# perform_cascades #
|
6
7
|
######################
|
7
8
|
|
8
9
|
def perform_cascades( module_self, action, hooked_instance, set_stack )
|
9
|
-
|
10
|
+
|
10
11
|
# This method is called when a ::ModuleCluster module is included or extended.
|
11
12
|
# It determines what modules should be included/extended and which should cascade.
|
12
13
|
|
@@ -130,15 +131,20 @@ module ::ModuleCluster::CascadeFeatures::PerformCascades
|
|
130
131
|
|
131
132
|
def cascade_block_into_hooked_instance( module_self, hooked_instance, set )
|
132
133
|
|
133
|
-
#
|
134
|
-
hooked_instance.
|
134
|
+
# subclasses already cascade due to #inherited behavior
|
135
|
+
unless hooked_instance.is_a?( Class )
|
135
136
|
|
136
|
-
|
137
|
-
|
137
|
+
# if we are supposed to cascade we need to extend with the ::ModuleCluster dependency module
|
138
|
+
hooked_instance.extend( set.dependency_module )
|
138
139
|
|
139
|
-
|
140
|
-
|
140
|
+
# and we call the set's definition method to cascade
|
141
|
+
hooked_instance.__send__( set.method, & set.runtime_block )
|
141
142
|
|
143
|
+
existing_inherit_hooks = module_self.cluster_stack.inherited_hooks
|
144
|
+
hooked_instance.cluster_stack.inherited_hooks.concat( existing_inherit_hooks )
|
145
|
+
|
146
|
+
end
|
147
|
+
|
142
148
|
end
|
143
149
|
|
144
150
|
#######################################
|
@@ -7,17 +7,16 @@ module ::ModuleCluster::CascadeFeatures::Subclass
|
|
7
7
|
|
8
8
|
def inherited( hooked_instance )
|
9
9
|
|
10
|
-
# all future subclasses should receive cascading hook
|
11
|
-
hooked_instance.extend( ::ModuleCluster::CascadeFeatures::Subclass )
|
12
|
-
hooked_instance.cluster_stack.inherited_hooks.concat( cluster_stack.inherited_hooks )
|
13
|
-
|
14
10
|
::ModuleCluster::CascadeFeatures.perform_cascades( self,
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
:inherited,
|
12
|
+
hooked_instance,
|
13
|
+
cluster_stack.inherited_hooks )
|
14
|
+
|
15
|
+
# we don't call super because we don't want to run our inherited action multiple times
|
16
|
+
# that means if you are messing with #inherited on your own (whoever is reading this code)
|
17
|
+
# then you need to consider the order your #inherited will be inserted in relation to
|
18
|
+
# the one provided by module-cluster
|
18
19
|
|
19
|
-
super
|
20
|
-
|
21
20
|
end
|
22
21
|
|
23
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: module-cluster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-12 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'Provides methods for clustering modules so that when the main module
|
15
15
|
is included other modules are also included or extended, either before or after
|