Class: Archimate::Diff::Change

Inherits:
Difference show all
Defined in:
lib/archimate/diff/change.rb

Constant Summary

Constants inherited from Difference

Difference::ARRAY_RE, Difference::PATH_ROOT_SORT_ORDER

Instance Attribute Summary

Attributes inherited from Difference

#changed_from, #target

Instance Method Summary collapse

Methods inherited from Difference

#<=>, #==, #delete?, #insert?, #move?, #path_to_array, #summary_element

Constructor Details

#initialize(target, changed_from) ⇒ Change

Create a new Change difference

Parameters:



13
14
15
# File 'lib/archimate/diff/change.rb', line 13

def initialize(target, changed_from)
  super(target, changed_from)
end

Instance Method Details

#apply(to_model) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/archimate/diff/change.rb', line 23

def apply(to_model)
  unless to_model.is_a?(DataModel::Model)
    throw(
      TypeError,
      "Expected a Archimate::DataModel::Model, was a #{to_model.class}"
    )
  end
  target.change(to_model, changed_from.value)
  to_model
end

#change?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/archimate/diff/change.rb', line 34

def change?
  true
end

#kindObject



38
39
40
# File 'lib/archimate/diff/change.rb', line 38

def kind
  "Change"
end

#to_sObject



17
18
19
20
21
# File 'lib/archimate/diff/change.rb', line 17

def to_s
  # Note - the explicit to_s is required to access the DiffableArray
  #        implementation if the parent is an Array.
  "#{diff_type} #{changed_from.parent&.to_s} #{Color.color(target.to_s, :change)} changed to #{target.value}"
end