Class: CascadingConfiguration::Core::Module::ExtendedConfigurations::CompositingObjects
- Inherits:
-
CascadingConfiguration::Core::Module::ExtendedConfigurations
- Object
- Module
- CascadingConfiguration::Core::Module
- CascadingConfiguration::Core::Module::ExtendedConfigurations
- CascadingConfiguration::Core::Module::ExtendedConfigurations::CompositingObjects
- Defined in:
- lib/cascading_configuration/core/module/extended_configurations/compositing_objects.rb
Constant Summary
Constants inherited from CascadingConfiguration::Core::Module
DefaultEncapsulation, DefaultEncapsulationName
Instance Attribute Summary collapse
-
#compositing_object_class ⇒ Object
readonly
compositing_object_class #.
Attributes inherited from CascadingConfiguration::Core::Module
#ccm_aliases, #ccm_name, #default_encapsulation
Instance Method Summary collapse
-
#create_configuration(encapsulation, instance, name) ⇒ Object
create_configuration #.
-
#getter(encapsulation, instance, name) ⇒ Object
getter #.
-
#initialize(ccm_name, compositing_object_class = nil, default_encapsulation_or_encapsulation_name = ::CascadingConfiguration::Core:: Module::DefaultEncapsulation, *ccm_aliases) ⇒ CompositingObjects
constructor
initialize #.
-
#initialize_compositing_configuration_for_parent(encapsulation, instance, configuration_name) ⇒ Object
initialize_compositing_configuration_for_parent #.
-
#initialize_configuration(encapsulation, instance, name) ⇒ Object
initialize_configuration #.
-
#instance_getter(encapsulation, instance, name) ⇒ Object
instance_getter #.
-
#instance_setter(encapsulation, instance, name, value) ⇒ Object
instance_setter #.
-
#setter(encapsulation, instance, name, value) ⇒ Object
setter #.
Methods inherited from CascadingConfiguration::Core::Module::ExtendedConfigurations
#define_configurations, parse_extension_modules
Methods inherited from CascadingConfiguration::Core::Module
#define_cascading_definition_method, #define_configurations, #define_definition_methods, #define_instance_definition_method, #define_local_instance_definition_method, #define_module_definition_method, #define_object_definition_method
Methods included from EnableModuleSupport
Constructor Details
#initialize(ccm_name, compositing_object_class = nil, default_encapsulation_or_encapsulation_name = ::CascadingConfiguration::Core:: Module::DefaultEncapsulation, *ccm_aliases) ⇒ CompositingObjects
initialize #
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cascading_configuration/core/module/extended_configurations/compositing_objects.rb', line 9 def initialize( ccm_name, compositing_object_class = nil, default_encapsulation_or_encapsulation_name = ::CascadingConfiguration::Core:: Module::DefaultEncapsulation, *ccm_aliases ) super( ccm_name, default_encapsulation_or_encapsulation_name, *ccm_aliases ) @compositing_object_class = compositing_object_class end |
Instance Attribute Details
#compositing_object_class ⇒ Object (readonly)
compositing_object_class #
72 73 74 |
# File 'lib/cascading_configuration/core/module/extended_configurations/compositing_objects.rb', line 72 def compositing_object_class @compositing_object_class end |
Instance Method Details
#create_configuration(encapsulation, instance, name) ⇒ Object
create_configuration #
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cascading_configuration/core/module/extended_configurations/compositing_objects.rb', line 25 def create_configuration( encapsulation, instance, name ) unless compositing_object = encapsulation.get_configuration( instance, name ) super # initialize without initializing for parents # we will initialize for parents after initializing all instances for inheritance compositing_object = @compositing_object_class.new( nil, instance ) instance_controller = ::CascadingConfiguration::Core:: InstanceController.nearest_instance_controller( encapsulation, instance, name ) if instance_controller extension_modules = instance_controller.extension_modules_upward( name, encapsulation ) unless extension_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). compositing_object.extend( *extension_modules ) end end encapsulation.set_configuration( instance, name, compositing_object ) end return compositing_object end |
#getter(encapsulation, instance, name) ⇒ Object
getter #
106 107 108 109 110 |
# File 'lib/cascading_configuration/core/module/extended_configurations/compositing_objects.rb', line 106 def getter( encapsulation, instance, name ) return encapsulation.get_configuration( instance, name ) end |
#initialize_compositing_configuration_for_parent(encapsulation, instance, configuration_name) ⇒ Object
initialize_compositing_configuration_for_parent #
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/cascading_configuration/core/module/extended_configurations/compositing_objects.rb', line 132 def initialize_compositing_configuration_for_parent( encapsulation, instance, configuration_name ) unless compositing_object = encapsulation.get_configuration( instance, configuration_name ) compositing_object = create_configuration( encapsulation, instance, configuration_name ) end # if instance has a parent if parent = encapsulation.parent_for_configuration( instance, configuration_name ) # We are initializing for existing ancestors, but they may not have initialized yet - # so we need to make sure they did before we initialize for instance. # As long as our ancestor has an ancestor make sure that it has initialized for its parent. # We can break at the first ancestor that we hit that has initialized for parent # or if we run out of ancestors. parent_composite_object = encapsulation.get_configuration( parent, configuration_name ) parent_composite_object2 = nil if parent2 = encapsulation.parent_for_configuration( parent, configuration_name ) parent_composite_object2 = encapsulation.get_configuration( parent2, configuration_name ) end # if first parent for configuration isn't initialized yet, initialize it unless parent_composite_object and parent_composite_object.parent_composite_object.equal?( parent_composite_object2 ) parent_composite_object = initialize_compositing_configuration_for_parent( encapsulation, parent, configuration_name ) end unless compositing_object.parent_composite_object.equal?( parent_composite_object ) compositing_object.initialize_for_parent( parent_composite_object ) end end return compositing_object end |
#initialize_configuration(encapsulation, instance, name) ⇒ Object
initialize_configuration #
62 63 64 65 66 |
# File 'lib/cascading_configuration/core/module/extended_configurations/compositing_objects.rb', line 62 def initialize_configuration( encapsulation, instance, name ) initialize_compositing_configuration_for_parent( encapsulation, instance, name ) end |
#instance_getter(encapsulation, instance, name) ⇒ Object
instance_getter #
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/cascading_configuration/core/module/extended_configurations/compositing_objects.rb', line 116 def instance_getter( encapsulation, instance, name ) compositing_object = nil unless compositing_object = encapsulation.get_configuration( instance, name ) compositing_object = initialize_compositing_configuration_for_parent( encapsulation, instance, name ) end return compositing_object end |
#instance_setter(encapsulation, instance, name, value) ⇒ Object
instance_setter #
92 93 94 95 96 97 98 99 100 |
# File 'lib/cascading_configuration/core/module/extended_configurations/compositing_objects.rb', line 92 def instance_setter( encapsulation, instance, name, value ) # ensure our compositing object already exists instance_getter( encapsulation, instance, name ) # now we can set normally return setter( encapsulation, instance, name, value ) end |
#setter(encapsulation, instance, name, value) ⇒ Object
setter #
78 79 80 81 82 83 84 85 86 |
# File 'lib/cascading_configuration/core/module/extended_configurations/compositing_objects.rb', line 78 def setter( encapsulation, instance, name, value ) compositing_object = encapsulation.get_configuration( instance, name ) compositing_object.replace( value ) return compositing_object end |