Module: RTM::Merging::Occurrence

Includes:
MergeReifiable
Defined in:
lib/rtm/activerecord/merging.rb

Instance Method Summary collapse

Instance Method Details

#merge(other) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/rtm/activerecord/merging.rb', line 111

def merge(other)
  # 1. Create a new occurrence item, C.
  # -> we will instead just modify a

  # 2. Set C's [value] property to the value of A's [value] property. B's value is equal to that of A and need not be taken into account.
  # 3. Set C's [datatype] property to the value of A's [datatype] property. B's value is equal to that of A and need not be taken into account.
  # 4. Set C's [scope] property to the value of A's [scope] property. B's value is equal to that of A and need not be taken into account.
  # 5. Set C's [type] property to the value of A's [type] property. B's value is equal to that of A and need not be taken into account.
  # -> nothing to do till here

  # 6. Set C's [reifier] property to the value of A's [reifier] property if it is not null, and to the value of B's [reifier] property if A's property is null. If both A and B have non-null values, the topic items shall be merged, and the topic item resulting from the merge set as the value of C's [reifier] property.
  self.merge_reifiable other

  # 7. Set C's [item identifiers] property to the union of the values of A's and B's [item identifiers] properties.
  self.merge_item_identifiers other

  # 8. Remove A and B from the [occurrences] property of the topic item in their [parent] properties, and add C.
  #self.parent.occurrences.remove other

  # let the wrapper point to the new object
  #other.__setobj__(self.__getobj__) if self.respond_to?(:__getobj__) && other.respond_to?(:__setobj__)
  self.merge_rewrap other

  self
end