Class: Diagrams::Elements::GitCommit

Inherits:
Dry::Struct
  • Object
show all
Includes:
Types
Defined in:
lib/diagrams/elements/git_commit.rb

Overview

Represents a commit in a Gitgraph diagram.

Instance Method Summary collapse

Instance Method Details

#to_hHash{Symbol => String | Array<String> | Symbol}

Returns a hash representation suitable for serialization. Optional attributes are included only if they have non-nil values.

Returns:

  • (Hash{Symbol => String | Array<String> | Symbol})


21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/diagrams/elements/git_commit.rb', line 21

def to_h
  hash = {
    id:,
    parent_ids:,
    branch_name:,
    type:
  }
  hash[:message] = message if message
  hash[:tag] = tag if tag
  hash[:cherry_pick_source_id] = cherry_pick_source_id if cherry_pick_source_id
  hash
end