File: module_extension.rb

package info (click to toggle)
ruby-rgen 0.10.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,428 kB
  • sloc: ruby: 11,344; xml: 1,368; yacc: 72; makefile: 10
file content (42 lines) | stat: -rw-r--r-- 822 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require 'rgen/ecore/ecore_interface'
require 'rgen/metamodel_builder/intermediate/annotation'

module RGen

module MetamodelBuilder

# This module is used to extend modules which should be
# part of RGen metamodels
module ModuleExtension
  include RGen::ECore::ECoreInterface
  
  def annotation(hash)
    _annotations << Intermediate::Annotation.new(hash)
  end
  
  def _annotations
    @_annotations ||= []
  end

  def _constantOrder
    @_constantOrder ||= []
  end
  
  def final_method(m)
    @final_methods ||= []
    @final_methods << m
  end
  
  def method_added(m)
    raise "Method #{m} can not be redefined" if @final_methods && @final_methods.include?(m)
  end

  def self.extended(m)
    MetamodelBuilder::ConstantOrderHelper.moduleCreated(m)
  end

end

end

end