Class: Archimate::Diff::ArchimateReferenceableReference

Inherits:
ArchimateNodeReference show all
Defined in:
lib/archimate/diff/archimate_identified_node_reference.rb

Instance Attribute Summary

Attributes inherited from ArchimateNodeReference

#archimate_node

Instance Method Summary collapse

Methods inherited from ArchimateNodeReference

#==, for_node, #lookup_parent_in_model, #path, #recurse_lookup_in_model

Constructor Details

#initialize(archimate_node) ⇒ ArchimateReferenceableReference

Returns a new instance of ArchimateReferenceableReference.



8
9
10
11
12
13
14
15
16
# File 'lib/archimate/diff/archimate_identified_node_reference.rb', line 8

def initialize(archimate_node)
  unless archimate_node.is_a?(DataModel::Referenceable)
    raise(
      TypeError,
      "archimate_node is a #{archimate_node.class}, Referenceable was expected"
    )
  end
  super
end

Instance Method Details

#lookup_in_model(model) ⇒ Object

Raises:

  • (TypeError)


18
19
20
21
22
23
24
25
26
# File 'lib/archimate/diff/archimate_identified_node_reference.rb', line 18

def lookup_in_model(model)
  raise TypeError unless model.is_a?(DataModel::Model)
  # There can be only one Model so return the model argument if
  # this node reference is a Model. This escape is required in case
  # the Model this is being applied to has a different id than the
  # model of the attribute this reference refers to.
  return model if archimate_node.is_a?(DataModel::Model)
  model.lookup(archimate_node.id)
end

#parentObject



36
37
38
# File 'lib/archimate/diff/archimate_identified_node_reference.rb', line 36

def parent
  archimate_node.parent
end

#to_sObject



28
29
30
# File 'lib/archimate/diff/archimate_identified_node_reference.rb', line 28

def to_s
  archimate_node.to_s
end

#valueObject



32
33
34
# File 'lib/archimate/diff/archimate_identified_node_reference.rb', line 32

def value
  archimate_node
end