Class: CascadingConfiguration::Core::InstanceController

Inherits:
Module
  • Object
show all
Includes:
ParallelAncestry::Inheritance
Defined in:
lib/namespaces.rb,
lib/cascading_configuration/core/instance_controller.rb

Defined Under Namespace

Modules: Methods Classes: ExtensionModule, SupportModule

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance, default_encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation, constant = :Controller, extending = false) ⇒ InstanceController

initialize #



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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
# File 'lib/cascading_configuration/core/instance_controller.rb', line 72

def initialize( instance, 
                default_encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation, 
                constant = :Controller,
                extending = false )

  # Call to super is necessary for ParallelAncestry support.
  super()
  
  @instance = instance.extend( self )
  
  if @instance.is_a?( ::Module )
    initialize_constant_in_instance( constant )
    unless extending
      initialize_inheritance( @instance )
    end
  else
    initialize_constant_in_self
  end

  # We manage reference to self in singleton from here to avoid duplicative efforts.
  reference_to_self = self
  self.class.class_eval do
    @instance_controller[ instance ] = reference_to_self
  end
  
  # We need an encapsulation to manage automatic inheritance relations.
  @default_encapsulation = ::CascadingConfiguration::Core::
                             Encapsulation.encapsulation( default_encapsulation_or_name )
  
  # We also support arbitrary additional encapsulations.
  @encapsulations = { }
  
  @cascade_includes = ::Array::Unique.new( self )
  @cascade_extends = ::Array::Unique.new( self )
  
  @support_modules = { }
  
  @extension_modules = { }
      
end

Instance Attribute Details

#cascade_extendsObject (readonly)

cascade_extends #



265
266
267
# File 'lib/cascading_configuration/core/instance_controller.rb', line 265

def cascade_extends
  @cascade_extends
end

#cascade_includesObject (readonly)

cascade_includes #



259
260
261
# File 'lib/cascading_configuration/core/instance_controller.rb', line 259

def cascade_includes
  @cascade_includes
end

#default_encapsulationObject (readonly)

default_encapsulation #



247
248
249
# File 'lib/cascading_configuration/core/instance_controller.rb', line 247

def default_encapsulation
  @default_encapsulation
end

#instanceObject (readonly)

instance #



253
254
255
# File 'lib/cascading_configuration/core/instance_controller.rb', line 253

def instance
  @instance
end

Class Method Details

.create_instance_controller(instance, default_encapsulation_or_name = ::CascadingConfiguration::Core:: Module::DefaultEncapsulation, constant = :Controller, extending = false) ⇒ Object

self.create_instance_controller #



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cascading_configuration/core/instance_controller.rb', line 12

def self.create_instance_controller( instance,
                                     default_encapsulation_or_name = ::CascadingConfiguration::Core::
                                                                       Module::DefaultEncapsulation, 
                                     constant = :Controller,
                                     extending = false )
  
  instance_controller = nil
  
  unless instance_controller = @instance_controller[ instance ]
    instance_controller = new( instance, default_encapsulation_or_name, constant, extending )
  end
  
  return instance_controller
  
end

.instance_controller(instance, ensure_exists = false) ⇒ Object

self.instance_controller #



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/cascading_configuration/core/instance_controller.rb', line 32

def self.instance_controller( instance, ensure_exists = false )
  
  instance_controller_instance = nil
  
  unless instance_controller_instance = @instance_controller[ instance ]
    if ensure_exists
      exception_string = 'No module controller defined for :' << instance.to_s
      exception_string << '.'
      raise ::ArgumentError, exception_string
    end
  end

  return instance_controller_instance
  
end

.nearest_instance_controller(encapsulation, instance, name) ⇒ Object

self.nearest_instance_controller #



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/cascading_configuration/core/instance_controller.rb', line 52

def self.nearest_instance_controller( encapsulation, instance, name )
  
  instance_controller = nil
  
  this_parent = instance

  begin

    break if instance_controller = instance_controller( this_parent )

  end while this_parent = encapsulation.parent_for_configuration( this_parent, name )
  
  return instance_controller
  
end

Instance Method Details

#add_extension_modules(name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation, *extension_modules, &definer_block) ⇒ Object

add_extension_modules #



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/cascading_configuration/core/instance_controller.rb', line 271

def add_extension_modules( name, 
                           encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation, 
                           *extension_modules, 
                           & definer_block )

  encapsulation = ::CascadingConfiguration::Core::Encapsulation.encapsulation( encapsulation_or_name )
  
  if block_given?
    
    new_module = self.class::ExtensionModule.new( self, encapsulation, name, & definer_block )

    constant_name = encapsulation.encapsulation_name.to_s.to_camel_case + '_' << name.to_s
    const_set( constant_name, new_module )

    extension_modules.push( new_module )

  end
  
  extension_modules.reverse!
  
  if extension_modules_array = @extension_modules[ name ]
    extension_modules_array.concat( extension_modules )
  else
    @extension_modules[ name ] = extension_modules_array = extension_modules
  end
  
  return extension_modules_array
  
end

#alias_instance_method(alias_name, name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation) ⇒ Object

alias_instance_method #



657
658
659
660
661
662
663
664
665
666
667
668
669
# File 'lib/cascading_configuration/core/instance_controller.rb', line 657

def alias_instance_method( alias_name, 
                           name, 
                           encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation )

  aliased_method = false
  
  if instance_support = instance_support( encapsulation_or_name )
    aliased_method = instance_support.alias_method( alias_name, name )
  end
  
  return aliased_method

end

#alias_local_instance_method(alias_name, name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation) ⇒ Object

alias_local_instance_method #



688
689
690
691
692
693
694
695
696
697
698
699
700
# File 'lib/cascading_configuration/core/instance_controller.rb', line 688

def alias_local_instance_method( alias_name, 
                                 name, 
                                 encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation )

  aliased_method = false
  
  if local_instance_support = local_instance_support( encapsulation_or_name )
    aliased_method = local_instance_support.alias_method( alias_name, name, encapsulation_or_name )
  end
  
  return aliased_method

end

#alias_module_and_instance_methods(alias_name, name, encapsulation_or_name = ::CascadingConfiguration::Core:: Module::DefaultEncapsulation) ⇒ Object

alias_module_and_instance_methods #



764
765
766
767
768
769
770
771
772
# File 'lib/cascading_configuration/core/instance_controller.rb', line 764

def alias_module_and_instance_methods( alias_name, 
                                       name, 
                                       encapsulation_or_name = ::CascadingConfiguration::Core::
                                                                 Module::DefaultEncapsulation )
  
  alias_module_method( alias_name, name, encapsulation_or_name )
  alias_instance_method( alias_name, name, encapsulation_or_name )
  
end

#alias_module_method(alias_name, name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation) ⇒ Object

alias_module_method #



544
545
546
547
548
549
550
551
552
553
554
555
556
# File 'lib/cascading_configuration/core/instance_controller.rb', line 544

def alias_module_method( alias_name, 
                         name, 
                         encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation )

  aliased_method = false
  
  if singleton_support = singleton_support( encapsulation_or_name )
    aliased_method = singleton_support.alias_method( alias_name, name )
  end
  
  return aliased_method

end

#create_instance_support(encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation) ⇒ Object

create_instance_support #



466
467
468
469
470
471
472
473
474
475
476
# File 'lib/cascading_configuration/core/instance_controller.rb', line 466

def create_instance_support( encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation )

  return create_support( :instance, 
                         encapsulation_or_name, 
                         self.class::SupportModule::InstanceSupportModule, 
                         true, 
                         false, 
                         true, 
                         false )

end

#create_local_instance_support(encapsulation_or_name = ::CascadingConfiguration::Core:: Module::DefaultEncapsulation) ⇒ Object

create_local_instance_support #



492
493
494
495
496
497
# File 'lib/cascading_configuration/core/instance_controller.rb', line 492

def create_local_instance_support( encapsulation_or_name = ::CascadingConfiguration::Core::
                                                             Module::DefaultEncapsulation )

  return create_support( :local_instance, encapsulation_or_name, nil, false, true, false, false )

end

#create_singleton_support(encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation) ⇒ Object

create_singleton_support #



440
441
442
443
444
445
446
447
448
449
450
# File 'lib/cascading_configuration/core/instance_controller.rb', line 440

def create_singleton_support( encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation )

  return create_support( :singleton, 
                         encapsulation_or_name, 
                         self.class::SupportModule::SingletonSupportModule, 
                         false, 
                         true, 
                         false, 
                         true )

end

#create_support(module_type_name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation, support_module_class = ::CascadingConfiguration::Core::InstanceController::SupportModule, should_include = false, should_extend = false, should_cascade_includes = false, should_cascade_extends = false, module_constant_name = module_type_name.to_s.to_camel_case) ⇒ Object

create_support #



354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/cascading_configuration/core/instance_controller.rb', line 354

def create_support( module_type_name,
                    encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation,
                    support_module_class = ::CascadingConfiguration::Core::InstanceController::SupportModule,
                    should_include = false, 
                    should_extend = false, 
                    should_cascade_includes = false, 
                    should_cascade_extends = false,
                    module_constant_name = module_type_name.to_s.to_camel_case )

  encapsulation = ::CascadingConfiguration::Core::Encapsulation.encapsulation( encapsulation_or_name )
  
  # permit nil for support_module_class to default
  support_module_class ||= ::CascadingConfiguration::Core::InstanceController::SupportModule
  
  unless encapsulation_supports_hash = @support_modules[ encapsulation ]
    encapsulation_supports_hash = { }
    @support_modules[ encapsulation ] = encapsulation_supports_hash
  end
  
  unless support_module_instance = encapsulation_supports_hash[ module_type_name ]

    # New Instance
  
    support_module_instance = support_module_class.new( self, encapsulation, module_type_name )
  
    const_set( module_constant_name, support_module_instance )

    encapsulation_supports_hash[ module_type_name ] = support_module_instance
  
    # Cascades
  
    if should_cascade_includes
      @cascade_includes.push( support_module_instance ) 
    end
  
    if should_cascade_extends
      @cascade_extends.push( support_module_instance )      
    end
  
    # Includes/Extends
  
    if should_include
      case @instance
        # we can only include in modules
        when ::Module
          @instance.module_eval do
            include support_module_instance
          end
        # but we might be told to create instance support on instances, in which case we need to extend
        else
          @instance.extend( support_module_instance )
      end
    end
      
    if should_extend
      @instance.extend( support_module_instance )
    end

  end
  
  return support_module_instance
  
end

#define_configuration_methods(ccm, encapsulation_or_name, method_types, names, &definer_block) ⇒ Object

define_configuration_methods #



513
514
515
516
517
518
519
520
521
522
523
524
525
526
# File 'lib/cascading_configuration/core/instance_controller.rb', line 513

def define_configuration_methods( ccm, encapsulation_or_name, method_types, names, & definer_block )

  encapsulation = ::CascadingConfiguration::Core::Encapsulation.encapsulation( encapsulation_or_name )

  accessors = parse_names_for_accessors( *names )
  
  accessors.each do |this_name, this_write_name|
    define_getter( ccm, this_name, this_name, method_types, encapsulation )
    define_setter( ccm, this_name, this_write_name, method_types, encapsulation )
  end
  
  return accessors
  
end

#define_instance_method(name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation, &method_proc) ⇒ Object

define_instance_method #



594
595
596
597
598
599
600
# File 'lib/cascading_configuration/core/instance_controller.rb', line 594

def define_instance_method( name, 
                            encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation, 
                            & method_proc )

  return create_instance_support( encapsulation_or_name ).define_method( name, & method_proc )
  
end

#define_instance_method_if_support(name, encapsulation_or_name = ::CascadingConfiguration::Core:: Module::DefaultEncapsulation, &method_proc) ⇒ Object

define_instance_method_if_support #



640
641
642
643
644
645
646
647
648
649
650
651
# File 'lib/cascading_configuration/core/instance_controller.rb', line 640

def define_instance_method_if_support( name, 
                                       encapsulation_or_name = ::CascadingConfiguration::Core::
                                                                 Module::DefaultEncapsulation, 
                                       & method_proc )

  if instance_support = instance_support( encapsulation_or_name )
    instance_support.define_method( name, & method_proc )
  end 
  
  return self
  
end

#define_local_instance_method(name, encapsulation_or_name = ::CascadingConfiguration::Core:: Module::DefaultEncapsulation, &method_proc) ⇒ Object

define_local_instance_method #



675
676
677
678
679
680
681
682
# File 'lib/cascading_configuration/core/instance_controller.rb', line 675

def define_local_instance_method( name, 
                                  encapsulation_or_name = ::CascadingConfiguration::Core::
                                                            Module::DefaultEncapsulation, 
                                  & method_proc )

  return create_local_instance_support( encapsulation_or_name ).define_method( name, & method_proc )

end

#define_singleton_and_instance_methods(name, encapsulation_or_name, &method_proc) ⇒ Object

define_singleton_and_instance_methods #



742
743
744
745
746
747
# File 'lib/cascading_configuration/core/instance_controller.rb', line 742

def define_singleton_and_instance_methods( name, encapsulation_or_name, & method_proc )

  define_singleton_method( name, encapsulation_or_name, & method_proc )
  define_instance_method( name, encapsulation_or_name, & method_proc )

end

#define_singleton_method(name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation, &method_proc) ⇒ Object

define_singleton_method #



532
533
534
535
536
537
538
# File 'lib/cascading_configuration/core/instance_controller.rb', line 532

def define_singleton_method( name, 
                             encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation, 
                             & method_proc )

  return create_singleton_support( encapsulation_or_name ).define_method( name, & method_proc )

end

#define_singleton_method_and_instance_method_if_support(name, encapsulation_or_name, &method_proc) ⇒ Object

define_singleton_method_and_instance_method_if_support #



753
754
755
756
757
758
# File 'lib/cascading_configuration/core/instance_controller.rb', line 753

def define_singleton_method_and_instance_method_if_support( name, encapsulation_or_name, & method_proc )

  define_singleton_method( name, encapsulation_or_name, & method_proc )
  define_instance_method_if_support( name, encapsulation_or_name, & method_proc )

end

#extension_modules(name = nil, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation) ⇒ Object

extension_modules #



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/cascading_configuration/core/instance_controller.rb', line 305

def extension_modules( name = nil, 
                       encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation )
  
  encapsulation = ::CascadingConfiguration::Core::Encapsulation.encapsulation( encapsulation_or_name )
  
  extension_modules = nil
  
  if name
    extension_modules = @extension_modules[ name ]
  else
    extension_modules = @extension_modules
  end
  
  return extension_modules
  
end

#extension_modules_upward(name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation) ⇒ Object

extension_modules_upward #



326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/cascading_configuration/core/instance_controller.rb', line 326

def extension_modules_upward( name, 
                              encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation )
  
  extension_modules = [ ]
  
  encapsulation = ::CascadingConfiguration::Core::Encapsulation.encapsulation( encapsulation_or_name )
  
  this_ancestor = @instance
  
  begin
    
    if ancestor_controller = self.class.instance_controller( this_ancestor ) and
       these_modules = ancestor_controller.extension_modules( name, encapsulation )
      
      extension_modules.concat( these_modules )
    
    end
    
  end while this_ancestor = encapsulation.parent_for_configuration( this_ancestor, name )
  
  return extension_modules
  
end

#initialize_constant_in_instance(constant) ⇒ Object

initialize_constant_in_self #



117
118
119
120
121
# File 'lib/cascading_configuration/core/instance_controller.rb', line 117

def initialize_constant_in_instance( constant )

  @instance.const_set( constant, self )

end

#initialize_constant_in_selfObject

initialize_constant_in_self #



127
128
129
130
131
132
133
134
135
# File 'lib/cascading_configuration/core/instance_controller.rb', line 127

def initialize_constant_in_self
  
  hex_id_string = '0x%x' % ( @instance.__id__ << 1 )
  constant = 'ID_' << hex_id_string
  self.class.const_set( constant, self )
  
  return self
  
end

#initialize_encapsulation_for_inheriting_instance(encapsulation, parent_instance, instance) ⇒ Object

initialize_encapsulation_for_inheriting_instance #



237
238
239
240
241
# File 'lib/cascading_configuration/core/instance_controller.rb', line 237

def initialize_encapsulation_for_inheriting_instance( encapsulation, parent_instance, instance )

  encapsulation.register_child_for_parent( instance, parent_instance )
  
end

#initialize_inheriting_instance(parent_instance, instance, for_subclass = false, is_extending = false) ⇒ Object

initialize_inheriting_instance #



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/cascading_configuration/core/instance_controller.rb', line 141

def initialize_inheriting_instance( parent_instance, instance, for_subclass = false, is_extending = false )

  super

  initialize_encapsulation_for_inheriting_instance( @default_encapsulation, parent_instance, instance )
  @encapsulations.each do |this_encapsulation_name, this_encapsulation|
    initialize_encapsulations_for_inheriting_instance( this_encapsulation, parent_instance, instance )
  end
  
  # subclass eigenclass inheritance is automatic; re-extending will only mess it up
  unless for_subclass
    initialize_inheriting_instance_includes_extends( parent_instance, instance, is_extending )
  end
  
end

#initialize_inheriting_instance_extends(parent_instance, instance) ⇒ Object

initialize_inheriting_instance_extends #



200
201
202
203
204
205
206
207
# File 'lib/cascading_configuration/core/instance_controller.rb', line 200

def initialize_inheriting_instance_extends( parent_instance, instance )

  # We collect cascade extends in accumulating order (oldest => youngest), 
  # which means we need to reverse prior to including/extending 
  # (we need youngest => oldest).
  instance.extend( *@cascade_extends.reverse )

end

#initialize_inheriting_instance_includes(parent_instance, instance) ⇒ Object

initialize_inheriting_instance_includes #



183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/cascading_configuration/core/instance_controller.rb', line 183

def initialize_inheriting_instance_includes( parent_instance, instance )
  
  cascade_includes = @cascade_includes
  
  instance.module_eval do
    # We collect cascade extends in accumulating order (oldest => youngest), 
    # which means we need to reverse prior to including/extending 
    # (we need youngest => oldest).
    include( *cascade_includes.reverse )
  end
  
end

#initialize_inheriting_instance_includes_extends(parent_instance, instance, is_extending = false) ⇒ Object

initialize_inheriting_instance_includes_extends #



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/cascading_configuration/core/instance_controller.rb', line 161

def initialize_inheriting_instance_includes_extends( parent_instance, instance, is_extending = false )

  unless is_extending or @cascade_extends.empty?
    initialize_inheriting_instance_extends( parent_instance, instance )
  end
  
  unless @cascade_includes.empty?

    if is_extending
      initialize_inheriting_instance_includes_for_extend_crossover( parent_instance, instance )
    else
      initialize_inheriting_instance_includes( parent_instance, instance )
    end

  end
  
end

#initialize_inheriting_instance_includes_for_extend_crossover(parent_instance, instance) ⇒ Object

Normally we have module => module cascading where instance methods remain instance methods,

and singleton methods remain singleton methods. When a module extends another, however,
instance methods become singleton methods.


218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/cascading_configuration/core/instance_controller.rb', line 218

def initialize_inheriting_instance_includes_for_extend_crossover( parent_instance, instance )

  @cascade_includes.each do |this_include|
    case instance
      when ::Module
        unless instance.ancestors.include?( this_include )
          instance.extend( this_include )
        end
      else
        instance.extend( this_include )
    end
  end
  
end

#instance_support(encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation) ⇒ Object

instance_support #



482
483
484
485
486
# File 'lib/cascading_configuration/core/instance_controller.rb', line 482

def instance_support( encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation )

  return support( :instance, encapsulation_or_name )

end

#local_instance_support(encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation) ⇒ Object

local_instance_support #



503
504
505
506
507
# File 'lib/cascading_configuration/core/instance_controller.rb', line 503

def local_instance_support( encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation )

  return support( :local_instance, encapsulation_or_name )

end

#remove_instance_method(name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation) ⇒ Object

remove_instance_method #



606
607
608
609
610
611
612
613
614
615
616
617
# File 'lib/cascading_configuration/core/instance_controller.rb', line 606

def remove_instance_method( name, 
                            encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation )

  removed_method = false

  if instance_support = instance_support( encapsulation_or_name )
    removed_method = instance_support.remove_method( name )
  end
  
  return removed_method
  
end

#remove_local_instance_method(name, encapsulation_or_name = ::CascadingConfiguration::Core:: Module::DefaultEncapsulation) ⇒ Object

remove_local_instance_method #



706
707
708
709
710
711
712
713
714
715
716
717
718
# File 'lib/cascading_configuration/core/instance_controller.rb', line 706

def remove_local_instance_method( name, 
                                  encapsulation_or_name = ::CascadingConfiguration::Core::
                                                            Module::DefaultEncapsulation )

  removed_method = false

  if local_instance_support = local_instance_support( encapsulation_or_name )
    removed_method = local_instance_support.remove_method( name )
  end
  
  return removed_method
  
end

#remove_module_method(name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation) ⇒ Object

remove_module_method #



562
563
564
565
566
567
568
569
570
571
572
# File 'lib/cascading_configuration/core/instance_controller.rb', line 562

def remove_module_method( name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation )

  removed_method = false

  if singleton_support = singleton_support( encapsulation_or_name )
    removed_method = singleton_support.remove_method( name )
  end
  
  return removed_method
  
end

#singleton_support(encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation) ⇒ Object

singleton_support #



456
457
458
459
460
# File 'lib/cascading_configuration/core/instance_controller.rb', line 456

def singleton_support( encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation )

  return support( :singleton, encapsulation_or_name )

end

#support(module_type_name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation) ⇒ Object

support #



422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/cascading_configuration/core/instance_controller.rb', line 422

def support( module_type_name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation )
  
  support_instance = nil
  
  encapsulation = ::CascadingConfiguration::Core::Encapsulation.encapsulation( encapsulation_or_name )
  
  if encapsulation_supports_hash = @support_modules[ encapsulation ]
    support_instance = encapsulation_supports_hash[ module_type_name ]
  end
  
  return support_instance
  
end

#undef_instance_method(name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation) ⇒ Object

undef_instance_method #



623
624
625
626
627
628
629
630
631
632
633
634
# File 'lib/cascading_configuration/core/instance_controller.rb', line 623

def undef_instance_method( name, 
                           encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation )

  undefined_method = false

  if instance_support = instance_support( encapsulation_or_name )
    undefined_method = instance_support.undef_method( name )
  end
  
  return undefined_method
  
end

#undef_local_instance_method(name, encapsulation_or_name = ::CascadingConfiguration::Core:: Module::DefaultEncapsulation) ⇒ Object

undef_local_instance_method #



724
725
726
727
728
729
730
731
732
733
734
735
736
# File 'lib/cascading_configuration/core/instance_controller.rb', line 724

def undef_local_instance_method( name, 
                                 encapsulation_or_name = ::CascadingConfiguration::Core::
                                                           Module::DefaultEncapsulation )

  undefined_method = false

  if local_instance_support = local_instance_support( encapsulation_or_name )
    undefined_method = local_instance_support.undef_method( name )
  end
  
  return undefined_method
  
end

#undef_module_method(name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation) ⇒ Object

undef_module_method #



578
579
580
581
582
583
584
585
586
587
588
# File 'lib/cascading_configuration/core/instance_controller.rb', line 578

def undef_module_method( name, encapsulation_or_name = ::CascadingConfiguration::Core::Module::DefaultEncapsulation )

  undefined_method = false

  if singleton_support = singleton_support( encapsulation_or_name )
    undefined_method = singleton_support.undef_method( name )
  end
  
  return undefined_method
  
end