Class: Archimate::Diff::Conflicts::DeletedItemsReferencedConflict

Inherits:
BaseConflict
  • Object
show all
Defined in:
lib/archimate/diff/conflicts/deleted_items_referenced_conflict.rb

Overview

DeletedItemsReferencedConflict

This sort of conflict occurs when one change set has deleted an element that is referenced by id in the other change set.

For example:

In the local change set, an element with id “abc123” is deleted. In the remote change set, a child is inserted into a diagram with archimate_element = “abc123”. These two changes are in conflict.

Instance Method Summary collapse

Methods inherited from BaseConflict

#conflicts, #diff_combinations, #diff_iterations, #initialize

Constructor Details

This class inherits a constructor from Archimate::Diff::Conflicts::BaseConflict

Instance Method Details

#describeObject



19
20
21
# File 'lib/archimate/diff/conflicts/deleted_items_referenced_conflict.rb', line 19

def describe
  "Checking for Deleted items in one change set are referenced in the other change set"
end

#diff_conflicts(diff1, diff2) ⇒ Object

TODO: This is simple, but might be slow. If it is, then override the conflicts method to prevent calculating referenced_identified_nodes methods



57
58
59
# File 'lib/archimate/diff/conflicts/deleted_items_referenced_conflict.rb', line 57

def diff_conflicts(diff1, diff2)
  diff2.target.value.referenced_identified_nodes.include?(diff1.target.value.id)
end

#filter1lambda

Filters a changeset to potentially conflicting diffs (making the set of combinations to check smaller)

Returns:

  • (lambda)

    a filter to limit diffs to Delete type



27
28
29
# File 'lib/archimate/diff/conflicts/deleted_items_referenced_conflict.rb', line 27

def filter1
  ->(diff) { diff.delete? && diff.target.value.is_a?(DataModel::Referenceable) }
end

#filter2lambda

Filters a changeset to potentially conflicting diffs (making the set of combinations to check smaller)

Returns:

  • (lambda)

    a filter to limit diffs to other than Delete type



36
37
38
# File 'lib/archimate/diff/conflicts/deleted_items_referenced_conflict.rb', line 36

def filter2
  ->(diff) { !diff.delete? }
end