Module: Archimate::DataModel::Relationships

Defined in:
lib/archimate/data_model/relationships.rb

Overview

Relationship Classifications: Structural, Dynamic, Dependency, Other

  • No relationships are allowed between two relationships

  • All relationships connected with relationship connectors must be of the same type

  • A chain of relationships of the same type that connects two elements, and is in turn connected via relationship connectors, is valid only if a direct relationship of that same type between those two elements is valid

  • A relationship connecting an element with a second relationship can only be an aggregation, composition, or association; aggregation or composition are valid only from a composite element to that second relationship

Aggregation, composition, and specialization relationships are always permitted between two elements of the same type, and association is always allowed between any two elements, and between any element and relationship.

Defined Under Namespace

Classes: Access, Aggregation, AndJunction, Assignment, Association, Composition, Flow, Influence, Junction, OrJunction, Realization, Serving, Specialization, Triggering

Class Method Summary collapse

Class Method Details

.===(other) ⇒ Object



222
223
224
# File 'lib/archimate/data_model/relationships.rb', line 222

def self.===(other)
  constants.map(&:to_s).include?(str_filter(other))
end

.classesObject



237
238
239
# File 'lib/archimate/data_model/relationships.rb', line 237

def self.classes
  constants.map { |cls_name| const_get(cls_name) }
end

.create(*args) ⇒ Object



211
212
213
214
215
216
217
218
219
220
# File 'lib/archimate/data_model/relationships.rb', line 211

def self.create(*args)
  # type = args[0].delete(:type)
  # cls_name = type.strip.sub(/Relationship$/, '')
  # cls_name = RELATIONSHIP_SUBSTITUTIONS.fetch(cls_name, cls_name)
  cls_name = str_filter(args[0].delete(:type))
  Relationships.const_get(cls_name).new(*args)
rescue NameError => err
  Archimate::Logging.error "An invalid relationship type '#{cls_name}' was used to create a Relationship"
  raise err
end

.defaultObject



241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/archimate/data_model/relationships.rb', line 241

def self.default
  [
    Relationships::Access,
    Relationships::Aggregation,
    Relationships::Assignment,
    Relationships::Association,
    Relationships::Composition,
    Relationships::Flow,
    Relationships::Realization,
    Relationships::Specialization,
    Relationships::Triggering,
    Relationships::Serving
  ].freeze
end

.str_filter(str) ⇒ Object



226
227
228
229
230
231
232
233
234
235
# File 'lib/archimate/data_model/relationships.rb', line 226

def self.str_filter(str)
  relationship_substitutions = {
    "Realisation" => "Realization",
    "Specialisation" => "Specialization",
    "UsedBy" => "Serving"
  }.freeze

  cls_name = str.strip.sub(/Relationship$/, '')
  relationship_substitutions.fetch(cls_name, cls_name)
end