Module: RGen::ECore::ECoreInterface

Included in:
MetamodelBuilder::MMBase, MetamodelBuilder::ModuleExtension
Defined in:
lib/rgen/ecore/ecore_interface.rb

Overview

Mixin to provide access to the ECore model describing a Ruby class or module built using MetamodelBuilder. The module should be used to extend a class or module, i.e. to make its methods class methods.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.clear_ecore_cacheObject

This method can be used to clear the ecore cache after the metamodel classes or modules have been changed; the ecore model will be recreated on next access to the ecore method Beware, the ecore cache is global, i.e. for all metamodels.



34
35
36
37
# File 'lib/rgen/ecore/ecore_interface.rb', line 34

def self.clear_ecore_cache
  require 'rgen/ecore/ruby_to_ecore'
  @@transformer = RubyToECore.new
end

Instance Method Details

#_set_ecore_internal(ecore) ⇒ Object

:nodoc:



39
40
41
# File 'lib/rgen/ecore/ecore_interface.rb', line 39

def _set_ecore_internal(ecore) # :nodoc:
  @ecore = ecore
end

#ecoreObject

This method will lazily build to ECore model element belonging to the calling class or module using RubyToECore. Alternatively, the ECore model element can be provided up front. This is used when the Ruby metamodel classes and modules are created from ECore.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rgen/ecore/ecore_interface.rb', line 17

def ecore
  if defined?(@ecore)
    @ecore
  else
    unless defined?(@@transformer)
      require 'rgen/ecore/ruby_to_ecore'
      @@transformer = RubyToECore.new
    end
    @@transformer.trans(self)
  end
end