Class: Archimate::DataModel::Element
- Inherits:
-
Object
- Object
- Archimate::DataModel::Element
- Includes:
- Comparison
- Defined in:
- lib/archimate/data_model/element.rb
Overview
Possible Make this abstract with concrete implementations for all valid element types
A base element type that can be extended by concrete ArchiMate types.
Note that ElementType is abstract, so one must have derived types of this type. This is indicated in xml by having a tag name of element
and an attribute of xsi:type=“BusinessRole” where BusinessRole
is a derived type from [ElementType].
Instance Attribute Summary collapse
- #documentation ⇒ PreservedLangString, NilClass
- #id ⇒ String readonly
- #name ⇒ LangString, NilClass readonly
- #properties ⇒ Array<Property> readonly
- #type ⇒ String, NilClass readonly
Instance Method Summary collapse
-
#diagrams ⇒ Object
Diagrams that this element is referenced in.
-
#initialize(id:, name:, documentation: nil, type: nil, properties: []) ⇒ Element
constructor
A new instance of Element.
- #layer ⇒ Object
-
#merge(element) ⇒ Object
Copy any attributes/docs, etc.
-
#relationships ⇒ Object
Relationships that this element is referenced in.
- #to_s ⇒ Object
Methods included from Comparison
#==, #[], #dig, #each, #hash, included, #pretty_print, #to_h
Constructor Details
#initialize(id:, name:, documentation: nil, type: nil, properties: []) ⇒ Element
Returns a new instance of Element.
38 39 40 41 42 43 44 |
# File 'lib/archimate/data_model/element.rb', line 38 def initialize(id:, name:, documentation: nil, type: nil, properties: []) @id = id @name = name @documentation = documentation @type = type @properties = properties end |
Instance Attribute Details
#documentation ⇒ PreservedLangString, NilClass
25 |
# File 'lib/archimate/data_model/element.rb', line 25 model_attr :documentation, writable: true |
#id ⇒ String (readonly)
19 |
# File 'lib/archimate/data_model/element.rb', line 19 model_attr :id |
#name ⇒ LangString, NilClass (readonly)
22 |
# File 'lib/archimate/data_model/element.rb', line 22 model_attr :name |
#properties ⇒ Array<Property> (readonly)
36 |
# File 'lib/archimate/data_model/element.rb', line 36 model_attr :properties |
#type ⇒ String, NilClass (readonly)
33 |
# File 'lib/archimate/data_model/element.rb', line 33 model_attr :type |
Instance Method Details
#diagrams ⇒ Object
Diagrams that this element is referenced in.
55 56 57 58 59 |
# File 'lib/archimate/data_model/element.rb', line 55 def diagrams @diagrams ||= in_model.diagrams.select do |diagram| diagram.element_ids.include?(id) end end |
#layer ⇒ Object
50 51 52 |
# File 'lib/archimate/data_model/element.rb', line 50 def layer Layers.for_element(type) end |
#merge(element) ⇒ 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
73 74 75 76 77 78 |
# File 'lib/archimate/data_model/element.rb', line 73 def merge(element) super element.diagrams.each { |diagram| diagram.replace(element, self) } element.relationships.each { |relationship| relationship.replace(element, self) } element.organization.remove(element.id) end |
#relationships ⇒ Object
Relationships that this element is referenced in.
62 63 64 65 66 |
# File 'lib/archimate/data_model/element.rb', line 62 def relationships @relationships ||= in_model.relationships.select do |relationship| relationship.source == id || relationship.target == id end end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/archimate/data_model/element.rb', line 46 def to_s Archimate::Color.layer_color(layer, "#{type}<#{id}>[#{name}]") end |