Class: CascadingConfiguration::Core::InstanceController::ExtensionModule
- Inherits:
-
Module
- Object
- Module
- CascadingConfiguration::Core::InstanceController::ExtensionModule
- Defined in:
- lib/cascading_configuration/core/instance_controller/extension_module.rb
Instance Attribute Summary collapse
-
#configuration_name ⇒ Object
readonly
configuration_name #.
-
#encapsulation ⇒ Object
readonly
encapsulation #.
-
#instance_controller ⇒ Object
readonly
instance_controller #.
Instance Method Summary collapse
-
#alias_method(alias_name, method_name) ⇒ Object
alias_method #.
-
#create_pending_aliases(configuration_instance) ⇒ Object
create_pending_aliases #.
-
#extended(configuration_instance) ⇒ Object
extended #.
-
#initialize(instance_controller, encapsulation, configuration_name, &definer_block) ⇒ ExtensionModule
constructor
initialize #.
Constructor Details
#initialize(instance_controller, encapsulation, configuration_name, &definer_block) ⇒ ExtensionModule
initialize #
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/cascading_configuration/core/instance_controller/extension_module.rb', line 8 def initialize( instance_controller, encapsulation, configuration_name, & definer_block ) @instance_controller = instance_controller @encapsulation = encapsulation @configuration_name = configuration_name @pending_aliases = { } if block_given? module_eval( & definer_block ) end end |
Instance Attribute Details
#configuration_name ⇒ Object (readonly)
configuration_name #
48 49 50 |
# File 'lib/cascading_configuration/core/instance_controller/extension_module.rb', line 48 def configuration_name @configuration_name end |
#encapsulation ⇒ Object (readonly)
encapsulation #
42 43 44 |
# File 'lib/cascading_configuration/core/instance_controller/extension_module.rb', line 42 def encapsulation @encapsulation end |
#instance_controller ⇒ Object (readonly)
instance_controller #
36 37 38 |
# File 'lib/cascading_configuration/core/instance_controller/extension_module.rb', line 36 def instance_controller @instance_controller end |
Instance Method Details
#alias_method(alias_name, method_name) ⇒ Object
alias_method #
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/cascading_configuration/core/instance_controller/extension_module.rb', line 82 def alias_method( alias_name, method_name ) aliased_method = false # if we don't respond to method, store it away so that we can alias it at extend time if method_defined?( method_name ) super aliased_method = true else @pending_aliases[ alias_name ] = method_name end return aliased_method end |
#create_pending_aliases(configuration_instance) ⇒ Object
create_pending_aliases #
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/cascading_configuration/core/instance_controller/extension_module.rb', line 54 def create_pending_aliases( configuration_instance ) created_aliases = false unless @pending_aliases.empty? pending_aliases = @pending_aliases eigenclass = class << configuration_instance ; self ; end eigenclass.instance_eval do pending_aliases.delete_if do |this_alias_name, this_method_name| should_delete = false if method_defined?( this_method_name ) alias_method( this_alias_name, this_method_name ) should_delete = true end should_delete end end created_aliases = true end return created_aliases end |
#extended(configuration_instance) ⇒ Object
extended #
26 27 28 29 30 |
# File 'lib/cascading_configuration/core/instance_controller/extension_module.rb', line 26 def extended( configuration_instance ) create_pending_aliases( configuration_instance ) end |