Class: Sbom::Data::Relationship

Inherits:
Object
  • Object
show all
Defined in:
lib/sbom/data/relationship.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source: nil, target: nil, relationship_type: nil) ⇒ Relationship

Returns a new instance of Relationship.



10
11
12
13
14
15
16
17
18
# File 'lib/sbom/data/relationship.rb', line 10

def initialize(source: nil, target: nil, relationship_type: nil)
  @source = source
  @target = target
  @relationship_type = relationship_type&.strip
  @source_id = nil
  @target_id = nil
  @source_type = nil
  @target_type = nil
end

Instance Attribute Details

#relationship_typeObject

Returns the value of attribute relationship_type.



6
7
8
# File 'lib/sbom/data/relationship.rb', line 6

def relationship_type
  @relationship_type
end

#sourceObject

Returns the value of attribute source.



6
7
8
# File 'lib/sbom/data/relationship.rb', line 6

def source
  @source
end

#source_idObject

Returns the value of attribute source_id.



6
7
8
# File 'lib/sbom/data/relationship.rb', line 6

def source_id
  @source_id
end

#source_typeObject

Returns the value of attribute source_type.



6
7
8
# File 'lib/sbom/data/relationship.rb', line 6

def source_type
  @source_type
end

#targetObject

Returns the value of attribute target.



6
7
8
# File 'lib/sbom/data/relationship.rb', line 6

def target
  @target
end

#target_idObject

Returns the value of attribute target_id.



6
7
8
# File 'lib/sbom/data/relationship.rb', line 6

def target_id
  @target_id
end

#target_typeObject

Returns the value of attribute target_type.



6
7
8
# File 'lib/sbom/data/relationship.rb', line 6

def target_type
  @target_type
end

Instance Method Details

#reset!Object



20
21
22
23
24
25
26
27
28
# File 'lib/sbom/data/relationship.rb', line 20

def reset!
  @source = nil
  @target = nil
  @relationship_type = nil
  @source_id = nil
  @target_id = nil
  @source_type = nil
  @target_type = nil
end

#to_hObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/sbom/data/relationship.rb', line 30

def to_h
  {
    source: @source,
    target: @target,
    type: @relationship_type,
    source_id: @source_id,
    target_id: @target_id,
    source_type: @source_type,
    target_type: @target_type
  }.compact
end