Class: Import_Module::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb,
lib/carat-dev/import-module/import-module-0.81/lib/import-module-single-thread.rb

Overview

kk

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Target

Returns a new instance of Target.



218
219
220
221
222
223
224
225
226
227
228
# File 'lib/carat-dev/import-module/import-module-0.81/lib/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

Instance Attribute Details

#klassObject

Returns the value of attribute klass.



207
208
209
# File 'lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb', line 207

def klass
  @klass
end

#meth_noObject (readonly)

Returns the value of attribute meth_no.



206
207
208
# File 'lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb', line 206

def meth_no
  @meth_no
end

#orig_methodsObject

Returns the value of attribute orig_methods.



208
209
210
# File 'lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb', line 208

def orig_methods
  @orig_methods
end

#privatesObject

Returns the value of attribute privates.



209
210
211
# File 'lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb', line 209

def privates
  @privates
end

#protectedsObject

Returns the value of attribute protecteds.



209
210
211
# File 'lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb', line 209

def protecteds
  @protecteds
end

#publicsObject

Returns the value of attribute publics.



209
210
211
# File 'lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb', line 209

def publics
  @publics
end

#saved_methodsObject

Returns the value of attribute saved_methods.



208
209
210
# File 'lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb', line 208

def saved_methods
  @saved_methods
end

#scopesObject (readonly)

Returns the value of attribute scopes.



206
207
208
# File 'lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb', line 206

def scopes
  @scopes
end

#stackObject

Returns the value of attribute stack.



207
208
209
# File 'lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb', line 207

def stack
  @stack
end

Class Method Details

.enclose(klass) ⇒ Object



211
212
213
214
215
216
# File 'lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb', line 211

def self.enclose(klass)
  s = self
  klass.instance_eval do
	@__IMPORT_MODULE_PREFIX_target ||= s.new(klass)
  end
end

Instance Method Details

#def_orig_methods(meths, pub_sw = false) ⇒ Object



234
235
236
237
238
239
240
241
242
243
# File 'lib/carat-dev/import-module/import-module-0.81/lib/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) ⇒ Object



245
246
247
248
249
250
251
252
253
254
# File 'lib/carat-dev/import-module/import-module-0.81/lib/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

#inspectObject



230
231
232
# File 'lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb', line 230

def inspect
  "Target(#{@klass})"
end