module-cluster 2.0.4 → 2.0.5
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.
data/lib/module/cluster.rb
CHANGED
@@ -46,6 +46,23 @@ module ::Module::Cluster
|
|
46
46
|
return ::Module::Cluster.cluster( self, name )
|
47
47
|
|
48
48
|
end
|
49
|
+
|
50
|
+
##################
|
51
|
+
# has_cluster? #
|
52
|
+
##################
|
53
|
+
|
54
|
+
###
|
55
|
+
# Get cluster for name. Will create cluster if it does not already exist.
|
56
|
+
#
|
57
|
+
# @param name Name of cluster.
|
58
|
+
#
|
59
|
+
# @return [true,false] Whether cluster name exists for self.
|
60
|
+
#
|
61
|
+
def has_cluster?( name )
|
62
|
+
|
63
|
+
return ::Module::Cluster.has_cluster?( self, name )
|
64
|
+
|
65
|
+
end
|
49
66
|
|
50
67
|
##################################################################################################
|
51
68
|
# private ######################################################################################
|
@@ -79,6 +96,8 @@ module ::Module::Cluster
|
|
79
96
|
@clusters[ instance ] = instance_hash = { }
|
80
97
|
end
|
81
98
|
|
99
|
+
name = name.to_sym
|
100
|
+
|
82
101
|
unless cluster_instance = instance_hash[ name ]
|
83
102
|
instance_hash[ name ] = cluster_instance = ::Module::Cluster::Cluster.new( instance, name )
|
84
103
|
end
|
@@ -87,6 +106,35 @@ module ::Module::Cluster
|
|
87
106
|
|
88
107
|
end
|
89
108
|
|
109
|
+
#######################
|
110
|
+
# self.has_cluster? #
|
111
|
+
#######################
|
112
|
+
|
113
|
+
###
|
114
|
+
# @private
|
115
|
+
#
|
116
|
+
# Return whether cluster exists for instance.
|
117
|
+
#
|
118
|
+
# @param instance
|
119
|
+
# Instance for which cluster is being queried.
|
120
|
+
#
|
121
|
+
# @param name
|
122
|
+
# Name of cluster for instance.
|
123
|
+
#
|
124
|
+
# @return [true,false] Whether cluster exists for instance.
|
125
|
+
#
|
126
|
+
def self.has_cluster?( instance, name )
|
127
|
+
|
128
|
+
has_cluster = false
|
129
|
+
|
130
|
+
if instance_hash = @clusters[ instance ]
|
131
|
+
has_cluster = instance_hash.has_key?( name.to_sym )
|
132
|
+
end
|
133
|
+
|
134
|
+
return has_cluster
|
135
|
+
|
136
|
+
end
|
137
|
+
|
90
138
|
##############################
|
91
139
|
# self.instance_controller #
|
92
140
|
##############################
|
@@ -185,7 +233,7 @@ module ::Module::Cluster
|
|
185
233
|
def self.hook_cluster_events( instance, hooked_instance, event_context )
|
186
234
|
|
187
235
|
requires_module_cluster_enable = false
|
188
|
-
|
236
|
+
|
189
237
|
# Subclass hooks always cascade to the first subclass.
|
190
238
|
# If it should casade for each subclass that has to be declared explicitly and will be handled below.
|
191
239
|
unless event_context == :subclass
|
@@ -316,7 +364,7 @@ module ::Module::Cluster
|
|
316
364
|
|
317
365
|
# if we have a block it runs last
|
318
366
|
if this_block = this_frame.block
|
319
|
-
|
367
|
+
instance.module_exec( hooked_instance, this_frame.owner, & this_block )
|
320
368
|
end
|
321
369
|
|
322
370
|
end
|
@@ -155,12 +155,14 @@ module ::Module::Cluster::Cluster::ClusterInterface
|
|
155
155
|
hook_controller = @instance_controller.after_include_controller
|
156
156
|
|
157
157
|
chain_proxy_instance = hook_controller.chain_proxy
|
158
|
+
|
159
|
+
chain_proxy_instance.cluster_name( @name ).context( *contexts )
|
158
160
|
|
159
161
|
if block_given?
|
160
|
-
|
162
|
+
chain_proxy_instance.action( & block )
|
161
163
|
end
|
162
164
|
|
163
|
-
return
|
165
|
+
return chain_proxy_instance
|
164
166
|
|
165
167
|
end
|
166
168
|
|
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: 2.0.
|
4
|
+
version: 2.0.5
|
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-07-
|
12
|
+
date: 2012-07-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Provides hooks via :included, :extended, :append_features, :extend_object,
|
15
15
|
:inherited. Define behavior at hooks via simple interface.
|