class Import_Module::Scope::Target

kk

Attributes

klass[RW]
meth_no[R]
orig_methods[RW]
privates[RW]
protecteds[RW]
publics[RW]
saved_methods[RW]
scopes[R]
stack[RW]

Public Class Methods

enclose(klass) click to toggle source
# File lib/algebra/import-module.rb, line 211
def self.enclose(klass)
  s = self
  klass.instance_eval do
          @__IMPORT_MODULE_PREFIX_target ||= s.new(klass)
  end
end
new(klass) click to toggle source
# File lib/algebra/import-module.rb, line 218
def initialize(klass)
  @scopes = {}
  @meth_no = {}
  @klass = klass
  @publics = @klass.public_instance_methods(true)#.find_all{|m| @klass.public_method_defined? m}
  @privates = @klass.private_instance_methods(true)#.find_all{|m| @klass.private_method_defined? m}
  @protecteds = @klass.protected_instance_methods(true)#.find_all{|m| @klass.protected_method_defined? m}
  @orig_methods = {}
  @saved_methods = {}
  resist_orig_methods
end

Public Instance Methods

def_orig_methods(meths, pub_sw = false) click to toggle source
# File lib/algebra/import-module.rb, line 234
def def_orig_methods(meths, pub_sw = false)
  # Store original methods of the root class
  @klass.module_eval do
    meths.__each__ do |meth|
      meth0 = Import_Module.name(meth, :orig)
      alias_method meth0, meth
      public meth0 if pub_sw
    end
  end
end
get_orig_methods(source) click to toggle source
# File lib/algebra/import-module.rb, line 245
def get_orig_methods(source)
  meths = []
  source.methods.__each__ do |meth|
    if @orig_methods[meth] && !@saved_methods[meth]
      @saved_methods[meth] = true
      meths.push meth
    end
  end
  meths
end
inspect() click to toggle source
# File lib/algebra/import-module.rb, line 230
def inspect
  "Target(#{@klass})"
end

Private Instance Methods

resist_orig_methods() click to toggle source
# File lib/algebra/import-module.rb, line 258
def resist_orig_methods
  @publics.__each__ do |x|
          @orig_methods[x] = true
  end
  @protecteds.__each__ do |x|
          @orig_methods[x] = true
  end
  @privates.__each__ do |x|
          @orig_methods[x] = true
  end
end