Class: CascadingConfiguration::Core::Module::BlockConfigurations::CascadingVariables
- Inherits:
-
CascadingConfiguration::Core::Module::BlockConfigurations
- Object
- Module
- CascadingConfiguration::Core::Module
- CascadingConfiguration::Core::Module::BlockConfigurations
- CascadingConfiguration::Core::Module::BlockConfigurations::CascadingVariables
- Defined in:
- lib/cascading_configuration/core/module/block_configurations/cascading_variables.rb
Constant Summary
Constants inherited from CascadingConfiguration::Core::Module
DefaultEncapsulation, DefaultEncapsulationName
Instance Attribute Summary
Attributes inherited from CascadingConfiguration::Core::Module
#ccm_aliases, #ccm_name, #default_encapsulation
Instance Method Summary collapse
-
#create_configuration(encapsulation, instance, name) ⇒ Object
Pending.
-
#getter(encapsulation, instance, name) ⇒ Object
Pending.
-
#initialize_compositing_configuration_for_parent(encapsulation, instance, configuration_name) ⇒ Object
Pending.
-
#instance_getter(encapsulation, instance, name) ⇒ Object
Pending.
-
#instance_setter(encapsulation, instance, name, value) ⇒ Object
Pending.
-
#setter(encapsulation, instance, name, value) ⇒ Object
Pending.
Methods inherited from CascadingConfiguration::Core::Module::BlockConfigurations
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, #initialize, #initialize_configuration
Methods included from EnableModuleSupport
Constructor Details
This class inherits a constructor from CascadingConfiguration::Core::Module
Instance Method Details
#create_configuration(encapsulation, instance, name) ⇒ Object
Pending.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cascading_configuration/core/module/block_configurations/cascading_variables.rb', line 10 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 ) 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 encapsulation.set_configuration( instance, name, compositing_object ) initialize_compositing_configuration_for_parent( encapsulation, instance, name ) end return compositing_object end |
#getter(encapsulation, instance, name) ⇒ Object
Pending.
58 59 60 61 62 |
# File 'lib/cascading_configuration/core/module/block_configurations/cascading_variables.rb', line 58 def getter( encapsulation, instance, name ) return encapsulation.get_configuration( instance, name ) end |
#initialize_compositing_configuration_for_parent(encapsulation, instance, configuration_name) ⇒ Object
Pending.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/cascading_configuration/core/module/block_configurations/cascading_variables.rb', line 103 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 ) # if first parent for configuration isn't initialized yet, initialize it unless parent_composite_object = encapsulation.get_configuration( parent, configuration_name ) parent_composite_object = initialize_compositing_configuration_for_parent( encapsulation, parent, configuration_name ) end unless compositing_object.parent_composite_object == parent_composite_object compositing_object.initialize_for_parent( parent_composite_object ) end end return compositing_object end |
#instance_getter(encapsulation, instance, name) ⇒ Object
Pending.
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/cascading_configuration/core/module/block_configurations/cascading_variables.rb', line 84 def instance_getter( encapsulation, instance, name ) cascading_value = nil if encapsulation.has_configuration_value?( instance, name ) cascading_value = encapsulation.get_configuration( instance, name ) else cascading_value = initialize_configuration_for_parent( encapsulation, instance, configuration_name ) end return cascading_value end |
#instance_setter(encapsulation, instance, name, value) ⇒ Object
Pending.
69 70 71 72 73 74 75 76 77 |
# File 'lib/cascading_configuration/core/module/block_configurations/cascading_variables.rb', line 69 def instance_setter( encapsulation, instance, name, value ) # ensure our compositing object already exists instance_getter( encapsulation, instance, name, value ) # now we can set normally return setter( encapsulation, instance, name, value ) end |
#setter(encapsulation, instance, name, value) ⇒ Object
Pending.
47 48 49 50 51 |
# File 'lib/cascading_configuration/core/module/block_configurations/cascading_variables.rb', line 47 def setter( encapsulation, instance, name, value ) return encapsulation.set_configuration( instance, name, value ) end |