Sha256: 7ccdb1d9ee6aa608fa3d50bbdf2f4071eb397732c87755a1dd2464f2780fbc14

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

require 'singleton'

class ProfilDefault
end

class ProfilDefaultSingleton < ProfilDefault
  include Singleton
end

#Profil racine.
#Toutes les extensions doivent ĂȘtre sous cet espace de nom.
module Mmtk_Profil
end

class Module
  #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
  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
  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
end

class Crdf_Resource
  def mtk_hello
    log.debug "\n>#{self.class.name}->Crdf_Resource::mtk_hello"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ontomde-core-1.0.4 lib/ontomde-core/profil.rb
ontomde-core-1.0.6 lib/ontomde-core/profil.rb
ontomde-core-2.0.0 lib/ontomde-core/profil.rb
ontomde-core-2.0.4 lib/ontomde-core/profil.rb
ontomde-core-2.0.5 lib/ontomde-core/profil.rb