Module: ModuleCluster::CascadeFeatures

Extended by:
PerformCascades
Defined in:
lib/module-cluster.rb,
lib/module-cluster/_private_/ModuleCluster/CascadeFeatures.rb

Defined Under Namespace

Modules: ClusterStack, PerformCascades, Subclass

Instance Method Summary collapse

Methods included from PerformCascades

cascade_block_into_hooked_instance, cascade_modules_into_hooked_instance, collect_block_runtime_result_modules, include_extend_modules, include_or_extend_hooked_instance, perform_cascades, should_include_or_extend_instance?

Instance Method Details

#append_features(hooked_instance) ⇒ Object

append_features #



10
11
12
13
14
15
16
17
18
19
# File 'lib/module-cluster/_private_/ModuleCluster/CascadeFeatures.rb', line 10

def append_features( hooked_instance )
  
  ::ModuleCluster::CascadeFeatures.perform_cascades( self, 
                                                     :prepend_include, 
                                                     hooked_instance, 
                                                     cluster_stack.prepend_include_hooks )
  
  super
  
end

#extend_object(hooked_instance) ⇒ Object

extend_object #



51
52
53
54
55
56
57
58
59
60
# File 'lib/module-cluster/_private_/ModuleCluster/CascadeFeatures.rb', line 51

def extend_object( hooked_instance )

  ::ModuleCluster::CascadeFeatures.perform_cascades( self, 
                                                     :prepend_extend, 
                                                     hooked_instance, 
                                                     cluster_stack.prepend_extend_hooks )
  
  super
  
end

#extended(hooked_instance) ⇒ Object

extended #



66
67
68
69
70
71
72
73
74
75
# File 'lib/module-cluster/_private_/ModuleCluster/CascadeFeatures.rb', line 66

def extended( hooked_instance )

  super

  ::ModuleCluster::CascadeFeatures.perform_cascades( self, 
                                                     :extend, 
                                                     hooked_instance, 
                                                     cluster_stack.extend_hooks )

end

#included(hooked_instance) ⇒ Object

included #



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/module-cluster/_private_/ModuleCluster/CascadeFeatures.rb', line 25

def included( hooked_instance )

  super

  ::ModuleCluster::CascadeFeatures.perform_cascades( self, 
                                                    :include, 
                                                    hooked_instance, 
                                                    cluster_stack.include_hooks )
  
  # if we are included in a class and we have cascading inherit hooks we need to move them over
  # append_features and included are both called for an inlucde, so we only need to do this in one
  if hooked_instance.is_a?( Class )

    unless cluster_stack.inherited_hooks.empty?
      hooked_instance.extend( ::ModuleCluster::Define::Block::Subclass )
      hooked_instance.cluster_stack.inherited_hooks.concat( cluster_stack.inherited_hooks )
    end

  end
  
end