Class: Module

Inherits:
Object show all
Defined in:
lib/ontomde-core/profil.rb

Instance Method Summary collapse

Instance Method Details

#method_added(a) ⇒ Object

Inclure le module courant dans le module principal de la métaclasse correspondante. (sucre syntaxique)

Exemple: module ProfileJava module Muml_NamedElement def doThis end end



24
25
26
27
28
29
# File 'lib/ontomde-core/profil.rb', line 24

def method_added(a)
  #log.debug "method added!! #{a} #{name}"
  #Module.nesting.each { |n| print("#{n.name},") }
  #super
  mtk_register if(a!=:mtk_register && a!=:method_added)
end

#mtk_registerObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ontomde-core/profil.rb', line 30

def mtk_register
  n=""; (ns=name.split(/::/)).each { |n| }
  #log.debug "registering #{name} #{ns[0]}"
  return if ns[0]!="Mmtk_Profil"
  @mtk_registered|=false
  return if @mtk_registered
  @mtk_registered=true

  cn=n.clone ; cn[0]="C"
  log.debug "Registering #{name} in #{n}"

  cmd="module #{name}\ndef mtk_hello\nprint(\"\\n>#{name}\")\nsuper\nend\nend\n"
  cmd=cmd+"module ::#{n}\ninclude #{name}\nend\n"
  if( :"#{cn}"==:Crdf_Resource )
    #TODO: HACK: module dynamique
    #log.debug "Re-Registering #{cn} in #{n}"
    sc= (:"#{cn}"!=:Crdf_Resource) ? "< ::Crdfs_Class ":""
    #log.debug "sc : #{sc} #{cn}"
    cmd=cmd+"class ::#{cn}\ninclude ::#{n}\nend\n"
    #log.debug "class ::#{cn}\ninclude ::#{n}\nend\n"
  end
  eval(cmd)
end