Class: Archimate::Diff::Move
- Inherits:
-
Difference
- Object
- Difference
- Archimate::Diff::Move
- Defined in:
- lib/archimate/diff/move.rb
Constant Summary
Constants inherited from Difference
Difference::ARRAY_RE, Difference::PATH_ROOT_SORT_ORDER
Instance Attribute Summary
Attributes inherited from Difference
Instance Method Summary collapse
-
#apply(to_model) ⇒ Object
TODO: patch is a better name than apply.
-
#initialize(target, changed_from) ⇒ Move
constructor
Create a new Move difference.
- #kind ⇒ Object
- #move? ⇒ Boolean
- #to_s ⇒ Object
Methods inherited from Difference
#<=>, #==, #change?, #delete?, #insert?, #path_to_array, #summary_element
Constructor Details
#initialize(target, changed_from) ⇒ Move
Create a new Move difference
14 15 16 |
# File 'lib/archimate/diff/move.rb', line 14 def initialize(target, changed_from) super(target, changed_from) end |
Instance Method Details
#apply(to_model) ⇒ Object
TODO: patch is a better name than apply
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/archimate/diff/move.rb', line 25 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.move(to_model, changed_from) to_model end |
#kind ⇒ Object
40 41 42 |
# File 'lib/archimate/diff/move.rb', line 40 def kind "Move" end |
#move? ⇒ Boolean
36 37 38 |
# File 'lib/archimate/diff/move.rb', line 36 def move? true end |
#to_s ⇒ Object
18 19 20 21 22 |
# File 'lib/archimate/diff/move.rb', line 18 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)} moved to #{target.array_index}" end |