Class: Archimate::DataModel::Connection
- Inherits:
-
Object
- Object
- Archimate::DataModel::Connection
show all
- Includes:
- Comparison
- Defined in:
- lib/archimate/data_model/connection.rb
Overview
Graphical connection type.
If the ‘relationshipRef’ attribute is present, the connection should reference an existing ArchiMate relationship.
If the connection is an ArchiMate relationship type, the connection’s label, documentation and properties may be determined (i.e inherited) from those in the referenced ArchiMate relationship. Otherwise the connection’s label, documentation and properties can be provided and will be additional to (or over-ride) those contained in the referenced ArchiMate relationship.
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#absolute_position ⇒ Object
TODO: Is this true for all or only Archi models?.
-
#description ⇒ Object
-
#element ⇒ Object
-
#initialize(id:, name: nil, documentation: nil, type: nil, source_attachment: nil, bendpoints: [], target_attachment: nil, source: nil, target: nil, relationship: nil, style: nil, properties: nil) ⇒ Connection
constructor
A new instance of Connection.
-
#nodes ⇒ Object
This is used when rendering a connection to connection relationship.
-
#referenced_identified_nodes ⇒ Object
-
#replace(entity, with_entity) ⇒ Object
-
#to_s ⇒ Object
-
#type_name ⇒ Object
Methods included from Comparison
#==, #[], #dig, #each, #hash, included, #pretty_print, #to_h
Constructor Details
#initialize(id:, name: nil, documentation: nil, type: nil, source_attachment: nil, bendpoints: [], target_attachment: nil, source: nil, target: nil, relationship: nil, style: nil, properties: nil) ⇒ Connection
Returns a new instance of Connection.
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/archimate/data_model/connection.rb', line 59
def initialize(id:, name: nil, documentation: nil, type: nil,
source_attachment: nil, bendpoints: [], target_attachment: nil,
source: nil, target: nil, relationship: nil, style: nil,
properties: nil)
@id = id
@name = name
@documentation = documentation
@type = type
@source_attachment = source_attachment
@bendpoints = bendpoints
@target_attachment = target_attachment
@source = source
@target = target
@relationship = relationship
@style = style
@properties = properties
end
|
Instance Attribute Details
#bendpoints ⇒ Array<Location>
39
|
# File 'lib/archimate/data_model/connection.rb', line 39
model_attr :bendpoints
|
23
|
# File 'lib/archimate/data_model/connection.rb', line 23
model_attr :documentation
|
#id ⇒ String
17
|
# File 'lib/archimate/data_model/connection.rb', line 17
model_attr :id
|
20
|
# File 'lib/archimate/data_model/connection.rb', line 20
model_attr :name
|
#properties ⇒ Array<Property>
57
|
# File 'lib/archimate/data_model/connection.rb', line 57
model_attr :properties
|
#relationship ⇒ Relationship, NilClass
51
|
# File 'lib/archimate/data_model/connection.rb', line 51
model_attr :relationship, comparison_attr: :id, writable: true
|
#source ⇒ ViewNode, NilClass
45
|
# File 'lib/archimate/data_model/connection.rb', line 45
model_attr :source, comparison_attr: :id, writable: true
|
#source_attachment ⇒ Location, NilClass
36
|
# File 'lib/archimate/data_model/connection.rb', line 36
model_attr :source_attachment
|
#style ⇒ Style, NilClass
54
|
# File 'lib/archimate/data_model/connection.rb', line 54
model_attr :style
|
#target ⇒ ViewNode, NilClass
48
|
# File 'lib/archimate/data_model/connection.rb', line 48
model_attr :target, comparison_attr: :id, writable: true
|
#target_attachment ⇒ Location, NilClass
42
|
# File 'lib/archimate/data_model/connection.rb', line 42
model_attr :target_attachment
|
#type ⇒ String, NilClass
33
|
# File 'lib/archimate/data_model/connection.rb', line 33
model_attr :type
|
Instance Method Details
#absolute_position ⇒ Object
TODO: Is this true for all or only Archi models?
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/archimate/data_model/connection.rb', line 114
def absolute_position
offset = Archimate::DataModel::Bounds.zero
el = parent.parent
while el.respond_to?(:bounds) && el.bounds
bounds = el.bounds
offset = offset.with(x: (offset.x || 0) + (bounds.x || 0), y: (offset.y || 0) + (bounds.y || 0))
el = el.parent.parent
end
offset
end
|
#description ⇒ Object
95
96
97
98
99
100
101
102
|
# File 'lib/archimate/data_model/connection.rb', line 95
def description
[
name.nil? ? nil : "#{name}: ",
source&.description,
relationship&.description,
target&.description
].compact.join(" ")
end
|
#element ⇒ Object
87
88
89
|
# File 'lib/archimate/data_model/connection.rb', line 87
def element
relationship
end
|
#nodes ⇒ Object
This is used when rendering a connection to connection relationship.
109
110
111
|
# File 'lib/archimate/data_model/connection.rb', line 109
def nodes
[]
end
|
#referenced_identified_nodes ⇒ Object
104
105
106
|
# File 'lib/archimate/data_model/connection.rb', line 104
def referenced_identified_nodes
[@source, @target, @relationship].compact
end
|
#replace(entity, with_entity) ⇒ Object
77
78
79
80
81
|
# File 'lib/archimate/data_model/connection.rb', line 77
def replace(entity, with_entity)
@relationship = with_entity.id if relationship == entity.id
@source = with_entity.id if source == entity.id
@target = with_entity.id if target == entity.id
end
|
#to_s ⇒ Object
91
92
93
|
# File 'lib/archimate/data_model/connection.rb', line 91
def to_s
"#{type_name} #{source.nil? ? 'nothing' : source} -> #{target.nil? ? 'nothing' : target}"
end
|
#type_name ⇒ Object
83
84
85
|
# File 'lib/archimate/data_model/connection.rb', line 83
def type_name
Archimate::Color.color("#{Archimate::Color.data_model('Connection')}[#{Archimate::Color.color(@name || '', %i[white underline])}]", :on_light_magenta)
end
|