Class: Archimate::DataModel::Insert
- Inherits:
-
Struct
- Object
- Struct
- Archimate::DataModel::Insert
- Defined in:
- lib/archimate/data_model/differentiable.rb
Overview
Let’s talk about diff…
Here are my expectations of diff:
Preconditions:
-
self is non-nil
-
self is a class that includes Comparison
Requirements for other
Not matching one of these is a programming error.
-
Other is nil
-
Other is an instance of the same class as self
Diff results
-
Diffing results in a list of Diff instances between
self
andother
-
Patching the list of diffs against self results in an instance that ==
other
Diff Container
A diff container is a top level entity that is meaningful in the user domain for example: [Element], [Relationship], [Diagram]. It collects and groups the smaller diffs into the things that changed by an entity tha makes sense to the user.
Diff structure
A diff contains a change to be applied in a particular context.
Use cases:
-
Delete a value that is a member of this class. Example: Delete the
a
member of a [Color] instance. -
A non-reference value replacing a value in a class. Example: Changing the
r
value of a [Color] with a different value. -
Updating the value of an attribute of a child. (or child’s child)
-
Deleting the value of an attribute of a child. (or child’s child)
-
For Array attributes with non-referenceable contents
-
Deleting a value from an array attribute
-
Inserting a value into an array attribute
-
Changing a value in an array attribute
-
-
For Array attributes with referenceable contents
-
Deleting a value from an array attribute (has an implication on if the entity is deleted from the model entirely)
-
Inserting a value into an array attribute (may need addtion to the model)
-
Changing a value in an array attribute (changing the entity id may require the implications of deletion and insertion as above)
-
When to stop?
When digging down into a diff operation, there are some natural stopping points:
-
When there is no more depth to dig
-
When the objects being compared are references to other entities, but do not belong to the current object being diffed.
-
When the object being diffed is a Diff container unto itself. For example: When diffing a model, the diff should include the order of elements referenced in the
elements
attribute, but shouldn’t continue with the diff of each element itself.
Complications
Object references
Since a patch operation produces an new replacement object, object references need to be handled. For example, given an Element
with id=3 if a patch changes this Element
‘s name, then the Element
in the model under Model#elements is replaced with a different instance, but a Relationship
that references the Element
is still pointing at a different instance and needs to be updated.
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path
80 81 82 |
# File 'lib/archimate/data_model/differentiable.rb', line 80 def path @path end |
#value ⇒ Object
Returns the value of attribute value
80 81 82 |
# File 'lib/archimate/data_model/differentiable.rb', line 80 def value @value end |