Class: CascadingConfiguration::Core::InstanceController::SupportModule
- Inherits:
-
Module
- Object
- Module
- CascadingConfiguration::Core::InstanceController::SupportModule
- Defined in:
- lib/cascading_configuration/core/instance_controller/support_module.rb
Direct Known Subclasses
Defined Under Namespace
Classes: InstanceSupportModule, SingletonSupportModule
Instance Method Summary collapse
-
#alias_method(alias_name, method_name) ⇒ Object
redefined to make public.
-
#cascade_new_support_for_child_modules ⇒ Object
cascade_new_support_for_child_modules #.
-
#child_modules ⇒ Object
child_modules #.
-
#define_method(method_name, *args, &block) ⇒ Object
redefined to make public.
-
#extended(class_or_module_or_instance) ⇒ Object
extended #.
-
#extended?(class_or_module_or_instance) ⇒ Boolean
extended? #.
-
#included(class_or_module) ⇒ Object
included #.
-
#included?(class_or_module) ⇒ Boolean
included? #.
-
#initialize(instance_controller, encapsulation_or_name, module_type_name) ⇒ SupportModule
constructor
initialize #.
-
#is_super_module?(module_instance) ⇒ Boolean
is_super_module? #.
-
#remove_method(method_name) ⇒ Object
redefined to make public.
-
#super_modules ⇒ Object
super_modules #.
-
#undef_method(method_name) ⇒ Object
redefined to make public.
Constructor Details
#initialize(instance_controller, encapsulation_or_name, module_type_name) ⇒ SupportModule
initialize #
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cascading_configuration/core/instance_controller/support_module.rb', line 16 def initialize( instance_controller, encapsulation_or_name, module_type_name ) encapsulation = ::CascadingConfiguration::Core::Encapsulation.encapsulation( encapsulation_or_name ) @instance_controller = instance_controller @encapsulation = encapsulation @module_type_name = module_type_name @included = ::Array::Unique.new( self ) @extended = ::Array::Unique.new( self ) # include modules like ourselves above us existing_super_modules = super_modules unless existing_super_modules.empty? # Modules are gathered from lowest ancestor upward. This means that they are already # in the proper order for include/extend (which usually we would have to reverse). include *existing_super_modules end cascade_new_support_for_child_modules end |
Instance Method Details
#alias_method(alias_name, method_name) ⇒ Object
redefined to make public
211 212 213 214 215 |
# File 'lib/cascading_configuration/core/instance_controller/support_module.rb', line 211 def alias_method( alias_name, method_name ) return super end |
#cascade_new_support_for_child_modules ⇒ Object
cascade_new_support_for_child_modules #
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/cascading_configuration/core/instance_controller/support_module.rb', line 166 def cascade_new_support_for_child_modules reference_to_self = self @included.each do |this_class_or_module| this_class_or_module.module_eval do include( reference_to_self ) end end @extended.each do |this_class_or_module_or_instance| this_class_or_module_or_instance.extend( self ) end child_modules.each do |this_child_module| this_child_module.module_eval do include( reference_to_self ) end # and continue down this tree this_child_module.cascade_new_support_for_child_modules end return self end |
#child_modules ⇒ Object
child_modules #
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/cascading_configuration/core/instance_controller/support_module.rb', line 137 def child_modules ancestor_controller = nil return @encapsulation.highest_children( @instance_controller.instance ) do |this_child| ancestor_controller = ::CascadingConfiguration::Core::InstanceController.instance_controller( this_child ) if ancestor_controller and ancestor_controller.support( @module_type_name, @encapsulation ) true else false end end.collect do |this_ancestor| ancestor_controller = ::CascadingConfiguration::Core::InstanceController.instance_controller( this_ancestor ) ancestor_controller.support( @module_type_name, @encapsulation ) end.uniq end |
#define_method(method_name, *args, &block) ⇒ Object
redefined to make public
200 201 202 203 204 |
# File 'lib/cascading_configuration/core/instance_controller/support_module.rb', line 200 def define_method( method_name, *args, & block ) return super end |
#extended(class_or_module_or_instance) ⇒ Object
extended #
55 56 57 58 59 60 61 |
# File 'lib/cascading_configuration/core/instance_controller/support_module.rb', line 55 def extended( class_or_module_or_instance ) super @extended.push( class_or_module_or_instance ) end |
#extended?(class_or_module_or_instance) ⇒ Boolean
extended? #
77 78 79 80 81 |
# File 'lib/cascading_configuration/core/instance_controller/support_module.rb', line 77 def extended?( class_or_module_or_instance ) return @extended.include?( class_or_module_or_instance ) end |
#included(class_or_module) ⇒ Object
included #
43 44 45 46 47 48 49 |
# File 'lib/cascading_configuration/core/instance_controller/support_module.rb', line 43 def included( class_or_module ) super @included.push( class_or_module ) end |
#included?(class_or_module) ⇒ Boolean
included? #
67 68 69 70 71 |
# File 'lib/cascading_configuration/core/instance_controller/support_module.rb', line 67 def included?( class_or_module ) return @included.include?( class_or_module ) end |
#is_super_module?(module_instance) ⇒ Boolean
is_super_module? #
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/cascading_configuration/core/instance_controller/support_module.rb', line 121 def is_super_module?( module_instance ) is_super_module = false if module_instance.is_a?( self.class ) is_super_module = true end return is_super_module end |
#remove_method(method_name) ⇒ Object
redefined to make public
222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/cascading_configuration/core/instance_controller/support_module.rb', line 222 def remove_method( method_name ) removed = false if method_defined?( method_name ) super removed = true end return removed end |
#super_modules ⇒ Object
super_modules #
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/cascading_configuration/core/instance_controller/support_module.rb', line 87 def super_modules ancestor_controller = nil return @encapsulation.lowest_parents( @instance_controller.instance ) do |this_parent| ancestor_controller = ::CascadingConfiguration::Core::InstanceController.instance_controller( this_parent ) if ancestor_controller and ancestor_support = ancestor_controller.support( @module_type_name, @encapsulation ) and is_super_module?( ancestor_support ) true else false end end.collect do |this_ancestor| ancestor_controller = ::CascadingConfiguration::Core::InstanceController.instance_controller( this_ancestor ) ancestor_controller.support( @module_type_name, @encapsulation ) end.uniq end |
#undef_method(method_name) ⇒ Object
redefined to make public
240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/cascading_configuration/core/instance_controller/support_module.rb', line 240 def undef_method( method_name ) undefined = false if method_defined?( method_name ) super undefined = true end return undefined end |