Module: Lite::Command::Internals::Resultable

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

Instance Method Summary collapse

Instance Method Details

#cidObject



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

def cid
  @cid ||= context.cid
end

#indexObject



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

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

#outcomeObject



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

def outcome
  return state if pending? || thrown?

  status
end

#resultsObject



24
25
26
# File 'lib/lite/command/internals/resultable.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
# File 'lib/lite/command/internals/resultable.rb', line 28

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