Module: RGen::ECore::ECoreBuilderMethods

Defined in:
lib/rgen/ecore/ecore_builder_methods.rb

Instance Method Summary collapse

Instance Method Details

#contains_1(name, type, argHash = {}) ⇒ Object Also known as: contains_one

containment reference shortcuts



58
59
60
# File 'lib/rgen/ecore/ecore_builder_methods.rb', line 58

def contains_1(name, type, argHash={})
  references_1(name, type, {:containment => true}.merge(argHash))  
end

#contains_1to1(name, type, oppositeName, argHash = {}) ⇒ Object Also known as: contains_one_to_one



68
69
70
# File 'lib/rgen/ecore/ecore_builder_methods.rb', line 68

def contains_1to1(name, type, oppositeName, argHash={})
  references_1to1(name, type, oppositeName, {:containment => true}.merge(argHash))  
end

#contains_1toN(name, type, oppositeName, argHash = {}) ⇒ Object Also known as: contains_one_to_many



73
74
75
# File 'lib/rgen/ecore/ecore_builder_methods.rb', line 73

def contains_1toN(name, type, oppositeName, argHash={})
  references_1toN(name, type, oppositeName, {:containment => true}.merge(argHash))  
end

#contains_N(name, type, argHash = {}) ⇒ Object Also known as: contains_many



63
64
65
# File 'lib/rgen/ecore/ecore_builder_methods.rb', line 63

def contains_N(name, type, argHash={})
  references_N(name, type, {:containment => true}.merge(argHash))  
end

#eAttr(name, type, argHash = {}, &block) ⇒ Object



6
7
8
# File 'lib/rgen/ecore/ecore_builder_methods.rb', line 6

def eAttr(name, type, argHash={}, &block)
  eAttribute(name, {:eType => type}.merge(argHash), &block)
end

#eBiRef(name, type, oppositeName, argHash = {}) ⇒ Object

create bidirectional reference at once

Raises:

  • (BuilderError)


15
16
17
18
19
20
21
22
23
24
# File 'lib/rgen/ecore/ecore_builder_methods.rb', line 15

def eBiRef(name, type, oppositeName, argHash={})
  raise BuilderError.new("eOpposite attribute not allowed for bidirectional references") \
    if argHash[:eOpposite] || argHash[:opposite_eOpposite]
  eReference(name, {:eType => type}.merge(argHash.reject{|k,v| k.to_s =~ /^opposite_/})) do 
    eReference oppositeName, {:eContainingClass => type, :eType => _context(2),
      :as => :eOpposite, :eOpposite => _context(1)}.
        merge(Hash[*(argHash.select{|k,v| k.to_s =~ /^opposite_/}.
          collect{|p| [p[0].to_s.sub(/^opposite_/,"").to_sym, p[1]]}.flatten)])
  end
end

#eRef(name, type, argHash = {}, &block) ⇒ Object Also known as: references_1, references_one



10
11
12
# File 'lib/rgen/ecore/ecore_builder_methods.rb', line 10

def eRef(name, type, argHash={}, &block)
  eReference(name, {:eType => type}.merge(argHash), &block)
end

#references_1to1(name, type, oppositeName, argHash = {}) ⇒ Object Also known as: references_one_to_one



36
37
38
# File 'lib/rgen/ecore/ecore_builder_methods.rb', line 36

def references_1to1(name, type, oppositeName, argHash={})
  eBiRef(name, type, oppositeName, {:upperBound => 1, :opposite_upperBound => 1}.merge(argHash))
end

#references_1toN(name, type, oppositeName, argHash = {}) ⇒ Object Also known as: references_one_to_many



41
42
43
# File 'lib/rgen/ecore/ecore_builder_methods.rb', line 41

def references_1toN(name, type, oppositeName, argHash={})
  eBiRef(name, type, oppositeName, {:upperBound => -1, :opposite_upperBound => 1}.merge(argHash))
end

#references_MtoN(name, type, oppositeName, argHash = {}) ⇒ Object Also known as: references_many_to_many



51
52
53
# File 'lib/rgen/ecore/ecore_builder_methods.rb', line 51

def references_MtoN(name, type, oppositeName, argHash={})
  eBiRef(name, type, oppositeName, {:upperBound => -1, :opposite_upperBound => -1}.merge(argHash))
end

#references_N(name, type, argHash = {}) ⇒ Object Also known as: references_many



31
32
33
# File 'lib/rgen/ecore/ecore_builder_methods.rb', line 31

def references_N(name, type, argHash={})
  eRef(name, type, {:upperBound => -1}.merge(argHash))
end

#references_Nto1(name, type, oppositeName, argHash = {}) ⇒ Object Also known as: references_many_to_one



46
47
48
# File 'lib/rgen/ecore/ecore_builder_methods.rb', line 46

def references_Nto1(name, type, oppositeName, argHash={})
  eBiRef(name, type, oppositeName, {:upperBound => 1, :opposite_upperBound => -1}.merge(argHash))
end