class Safrano::Relation
we represent a relation as a Set (unordered) of two end elements
Attributes
multiplicity[RW]
attr_reader :rid
Public Class Methods
new(arg)
click to toggle source
Calls superclass method
# File lib/odata/relations.rb, line 12 def initialize(arg) super(arg) @multiplicity = {} end
Public Instance Methods
each_endobj() { |first| ... }
click to toggle source
# File lib/odata/relations.rb, line 33 def each_endobj tmp = to_a.sort yield tmp.first yield tmp.last end
name()
click to toggle source
we need a from/to order independant OData
like name
# File lib/odata/relations.rb, line 27 def name x = sa.map(&:to_s) y = x.reverse [x.join('_'), y.join('_')].join('_') end
rid()
click to toggle source
we need a from/to order independant ID
# File lib/odata/relations.rb, line 22 def rid Safrano::RelationManager.build_id(self) end
sa()
click to toggle source
# File lib/odata/relations.rb, line 17 def sa sort end
set_multiplicity(obj, mult)
click to toggle source
# File lib/odata/relations.rb, line 39 def set_multiplicity(obj, mult) ms = mult.to_s raise ArgumentError unless include?(obj) case ms when '1', '*', '0..1' @multiplicity[obj] = ms else raise ArgumentError end end
with_metadata_info(xnamespace) { |name, bdprops| ... }
click to toggle source
# File lib/odata/relations.rb, line 51 def with_metadata_info(xnamespace) bdprops = [] each_endobj do |eo| bdprops << { type: "#{xnamespace}.#{eo}", role: eo, multiplicity: multiplicity[eo] } end yield name, bdprops end