Module: RTM::AR::IO::TOXTM1::Association

Defined in:
lib/rtm/activerecord/io/to_xtm1.rb

Instance Method Summary collapse

Instance Method Details

#to_xtm1Object

returns the XTM 2.0 representation of this association as an REXML::Element



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/rtm/activerecord/io/to_xtm1.rb', line 90

def to_xtm1
  warn("TOXTM1: Warning: outputting invalid Association #{self}") unless valid?
  # association = element association { reifiable, type, scope?, role+ }
  x = REXML::Element.new 'association'
  x.add_attribute('reifier', reifier.xtm1_id) if reifier
  item_identifiers.each { |ii| x << TOXTM1.ii(ii) } # itemIdentity
  x << TOXTM1.type(type) if type
  x << TOXTM1.scope(scope) unless scope.empty?
  roles.each { |r| x << r.to_xtm1 }
  x
end