Module: Lite::Command::Internals::Results

Defined in:
lib/lite/command/internals/results.rb

Instance Method Summary collapse

Instance Method Details

#cmd_idObject



14
15
16
# File 'lib/lite/command/internals/results.rb', line 14

def cmd_id
  @cmd_id ||= context.cmd_id ||= SecureRandom.uuid
end

#indexObject



10
11
12
# File 'lib/lite/command/internals/results.rb', line 10

def index
  @index ||= context.index ||= 0
end

#outcomeObject



18
19
20
21
22
# File 'lib/lite/command/internals/results.rb', line 18

def outcome
  return state if pending? || thrown?

  status
end

#resultsObject



24
25
26
# File 'lib/lite/command/internals/results.rb', line 24

def results
  @results ||= context.results ||= []
end

#to_hashObject Also known as: to_h



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/lite/command/internals/results.rb', line 28

def to_hash
  {
    index:,
    cmd_id:,
    command: self.class.name,
    outcome:,
    state:,
    status:,
    reason:,
    metadata:,
    caused_by: caused_by&.index,
    thrown_by: thrown_by&.index,
    runtime:
  }.compact
end