Class: Module::Cluster::InstanceController::HookController::ChainProxy
- Inherits:
-
Object
- Object
- Module::Cluster::InstanceController::HookController::ChainProxy
- Defined in:
- lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb
Overview
An InstanceController uses an InstanceController::HookController::ChainProxy to chain commands
that rely on chained state.
Instance Attribute Summary collapse
-
#cascades_to ⇒ Array<Symbol,nil>
readonly
Contexts (nil, :module, :class, :subclass, :instance) for which this instance cascades.
-
#contexts ⇒ Array<Symbol,nil>
readonly
Contexts (nil, :module, :class, :subclass, :instance) for which this instance is operative as a chain proxy.
-
#parent_hook_controller ⇒ Object
readonly
Hook controller for which this instance is operative as a chaining proxy.
Instance Method Summary collapse
-
#action {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that action should be performed at event hook in the context specified this chained declaration.
-
#before_extend {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that chained actions should be inserted into the event stack after the location in the same event stack where provided module(s) are specified to be extended.
-
#before_include {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that chained actions should be inserted into the event stack after the location in the same event stack where provided module(s) are specified to be included.
-
#before_include_or_extend {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
(also: #after_extend_or_include)
Declare that chained actions should be inserted into the event stack after the location in the same event stack where provided module(s) are specified to be included or extended.
-
#before_extend {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that chained actions should be inserted into the event stack prior to the location in the same event stack where provided module(s) are specified to be extended.
-
#before_include {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that chained actions should be inserted into the event stack prior to the location in the same event stack where provided module(s) are specified to be included.
-
#before_include_or_extend {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
(also: #before_extend_or_include)
Declare that chained actions should be inserted into the event stack prior to the location in the same event stack where provided module(s) are specified to be included or extended.
-
#cascade(context, ...) {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
(also: #cascade_to)
Declare contexts to which declarations made from this declaration chain should cascade.
-
#cluster_name(cluster_name) ⇒ Module::Cluster::InstanceController::ChainProxy
Set cluster name for which chained actions will be inserted in stack.
-
#context(context, ...) ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Set context for matching instance to determine whether to perform chained actions in stack.
-
#extend {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that modules should be extended at event hook in the context specified this chained declaration.
-
#extend_and_include {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that modules should be extended and included at event hook in the context specified this chained declaration.
-
#include {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that modules should be included at event hook in the context specified this chained declaration.
-
#include_and_extend {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that modules should be included and extended at event hook in the context specified this chained declaration.
-
#index(index) ⇒ Module::Cluster::InstanceController::ChainProxy
Set index where chained actions will be inserted in stack.
-
#initialize(parent_hook_controller) ⇒ ChainProxy
constructor
A new instance of ChainProxy.
-
#reset_state ⇒ Module::Cluster::InstanceController::ChainProxy
Reset internal state data so that proxy can be re-used for chaining in a new context.
Constructor Details
#initialize(parent_hook_controller) ⇒ ChainProxy
Returns a new instance of ChainProxy.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 17 def initialize( parent_hook_controller ) @parent_hook_controller = parent_hook_controller @contexts = [ ] @cascades_to = [ ] @index = -1 end |
Instance Attribute Details
#cascades_to ⇒ Array<Symbol,nil> (readonly)
Contexts (nil, :module, :class, :subclass, :instance) for which this instance cascades.
509 510 511 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 509 def cascades_to @cascades_to end |
#contexts ⇒ Array<Symbol,nil> (readonly)
Contexts (nil, :module, :class, :subclass, :instance) for which this instance is operative as a chain proxy.
496 497 498 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 496 def contexts @contexts end |
#parent_hook_controller ⇒ Object (readonly)
Hook controller for which this instance is operative as a chaining proxy.
422 423 424 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 422 def parent_hook_controller @parent_hook_controller end |
Instance Method Details
#action {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that action should be performed at event hook in the context
specified this chained declaration.
162 163 164 165 166 167 168 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 162 def action( & block ) @index = @parent_hook_controller.action_at_index( @index, @cluster_name, @contexts, @cascades_to, true, & block ) return self end |
#before_extend {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that chained actions should be inserted into the event stack after the location
in the same event stack where provided module(s) are specified to be extended.
346 347 348 349 350 351 352 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 346 def after_extend( *modules ) @index = parent_hook_controller.highest_index( :extend, *modules ) + 1 return self end |
#before_include {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that chained actions should be inserted into the event stack after the location
in the same event stack where provided module(s) are specified to be included.
320 321 322 323 324 325 326 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 320 def after_include( *modules ) @index = parent_hook_controller.highest_index( :include, *modules ) + 1 return self end |
#before_include_or_extend {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy Also known as: after_extend_or_include
Declare that chained actions should be inserted into the event stack after the location
in the same event stack where provided module(s) are specified to be included or extended.
373 374 375 376 377 378 379 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 373 def after_include_or_extend( *modules ) @index = parent_hook_controller.highest_index( :include_or_extend, *modules ) + 1 return self end |
#before_extend {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that chained actions should be inserted into the event stack prior to the location
in the same event stack where provided module(s) are specified to be extended.
239 240 241 242 243 244 245 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 239 def before_extend( *modules ) @index = parent_hook_controller.lowest_index( :extend, *modules ) return self end |
#before_include {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that chained actions should be inserted into the event stack prior to the location
in the same event stack where provided module(s) are specified to be included.
265 266 267 268 269 270 271 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 265 def before_include( *modules ) @index = parent_hook_controller.lowest_index( :include, *modules ) return self end |
#before_include_or_extend {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy Also known as: before_extend_or_include
Declare that chained actions should be inserted into the event stack prior to the location
in the same event stack where provided module(s) are specified to be included or extended.
292 293 294 295 296 297 298 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 292 def before_include_or_extend( *modules ) @index = parent_hook_controller.lowest_index( :include_or_extend, *modules ) return self end |
#cascade(context, ...) {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy Also known as: cascade_to
Declare contexts to which declarations made from this declaration chain should cascade.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 188 def cascade( *cascade_contexts, & block ) case cascade_contexts.count when 0 @cascades_to.clear @cascades_to.push( :any ) when 1 if cascade_contexts[ 0 ].nil? @cascades_to.clear else @cascades_to.replace( cascade_contexts ) end else @cascades_to.replace( cascade_contexts ) end if block_given? action( & block ) end return self end |
#cluster_name(cluster_name) ⇒ Module::Cluster::InstanceController::ChainProxy
Set cluster name for which chained actions will be inserted in stack.
458 459 460 461 462 463 464 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 458 def cluster_name( cluster_name ) @cluster_name = cluster_name return self end |
#context(context, ...) ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Set context for matching instance to determine whether to perform chained actions in stack.
396 397 398 399 400 401 402 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 396 def context( *contexts ) @contexts.replace( contexts ) return self end |
#extend {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that modules should be extended at event hook in the context specified this chained declaration.
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 70 def extend( *modules, & block ) @index = @parent_hook_controller.extend_at_index( @index, @cluster_name, @contexts, @cascades_to, true, *modules, & block ) return self end |
#extend_and_include {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that modules should be extended and included at event hook in the context
specified this chained declaration. Order is reversed from #include_and_extend.
134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 134 def extend_and_include( *modules, & block ) @index = @parent_hook_controller.extend_and_include_at_index( @index, @cluster_name, @contexts, @cascades_to, true, *modules, & block ) return self end |
#include {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that modules should be included at event hook in the context specified this chained declaration.
45 46 47 48 49 50 51 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 45 def include( *modules, & block ) @parent_hook_controller.include_at_index( @index, @cluster_name, @contexts, @cascades_to, true, *modules, & block ) return self end |
#include_and_extend {|hooked_instance| ... } ⇒ Module::Cluster::InstanceController::HookController::ChainProxy
Declare that modules should be included and extended at event hook in the context
specified this chained declaration. See also #extend_and_include.
102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 102 def include_and_extend( *modules, & block ) @index = @parent_hook_controller.include_and_extend_at_index( @index, @cluster_name, @contexts, @cascades_to, true, *modules, & block ) return self end |
#index(index) ⇒ Module::Cluster::InstanceController::ChainProxy
Set index where chained actions will be inserted in stack.
477 478 479 480 481 482 483 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 477 def index( index ) @index = index return self end |
#reset_state ⇒ Module::Cluster::InstanceController::ChainProxy
Reset internal state data so that proxy can be re-used for chaining in a new context.
435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb', line 435 def reset_state @cluster_name = nil @index = -1 @contexts.clear @cascades_to.clear return self end |