Class: Archimate::DataModel::Relationship
- Inherits:
-
Concept
- Object
- Dry::Struct
- ArchimateNode
- Referenceable
- Concept
- Archimate::DataModel::Relationship
- Defined in:
- lib/archimate/data_model/relationship.rb
Overview
A base relationship type that can be extended by concrete ArchiMate types.
Note that RelationshipType is abstract, so one must have derived types of this type. this is indicated in xml by having a tag name of “relationship” and an attribute of xsi:type=“AccessRelationship” where AccessRelationship is a derived type from RelationshipType.
Instance Attribute Summary
Attributes inherited from ArchimateNode
#parent_attribute_name, #struct_instance_variables
Instance Method Summary collapse
- #description ⇒ Object
-
#diagrams ⇒ Object
Diagrams that this element is referenced in.
-
#merge(relationship) ⇒ Object
Copy any attributes/docs, etc.
- #referenced_identified_nodes ⇒ Object
- #replace(entity, with_entity) ⇒ Object
- #source_element ⇒ Object
- #target_element ⇒ Object
- #to_s ⇒ Object
Methods inherited from ArchimateNode
#ancestors, #build_index, #clone, #compact!, #delete, #diff, #dup, #element_by_id, #id, #in_model, #in_model=, #initialize, #parent, #parent=, #path, #primitive?, #set, #with
Constructor Details
This class inherits a constructor from Archimate::DataModel::ArchimateNode
Instance Method Details
#description ⇒ Object
46 47 48 49 50 51 |
# File 'lib/archimate/data_model/relationship.rb', line 46 def description [ name.nil? ? nil : "#{name}:", FileFormats::ArchimateV2::RELATION_VERBS.fetch(type, nil) ].compact.join(" ") end |
#diagrams ⇒ Object
Diagrams that this element is referenced in.
66 67 68 69 70 |
# File 'lib/archimate/data_model/relationship.rb', line 66 def diagrams @diagrams ||= in_model.diagrams.select do |diagram| diagram.relationship_ids.include?(id) end end |
#merge(relationship) ⇒ Object
Copy any attributes/docs, etc. from each of the others into the original.
1. Child `label`s with different `xml:lang` attribute values
2. Child `documentation` (and different `xml:lang` attribute values)
3. Child `properties`
4. Any other elements
source and target don’t change on a merge
78 79 80 81 |
# File 'lib/archimate/data_model/relationship.rb', line 78 def merge(relationship) super access_type ||= relationship.access_type end |
#referenced_identified_nodes ⇒ Object
53 54 55 |
# File 'lib/archimate/data_model/relationship.rb', line 53 def referenced_identified_nodes [@source, @target].compact end |
#replace(entity, with_entity) ⇒ Object
34 35 36 37 |
# File 'lib/archimate/data_model/relationship.rb', line 34 def replace(entity, with_entity) @source = with_entity.id if source == entity.id @target = with_entity.id if target == entity.id end |
#source_element ⇒ Object
57 58 59 |
# File 'lib/archimate/data_model/relationship.rb', line 57 def source_element element_by_id(source) end |
#target_element ⇒ Object
61 62 63 |
# File 'lib/archimate/data_model/relationship.rb', line 61 def target_element element_by_id(target) end |
#to_s ⇒ Object
39 40 41 42 43 44 |
# File 'lib/archimate/data_model/relationship.rb', line 39 def to_s Archimate::Color.color( "#{Archimate::Color.data_model(type)}<#{id}>[#{Archimate::Color.color(name&.strip || '', %i[black underline])}]", :on_light_magenta ) + " #{source_element} -> #{target_element}" end |