Sha256: dea9e3dccc01b82248723eb77ea930bf1d5783f0b84d1a3057fe9edab5077c3b

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Lite
  module Command
    module Internals
      module Results

        def outcome
          return state if pending? || thrown?

          status
        end

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

        def to_h
          {
            index:,
            cmd_id:,
            command: self.class.name,
            outcome:,
            state:,
            status:,
            reason:,
            metadata:,
            caused_by: caused_by&.index,
            caused_exception: Utils.pretty_exception(caused_by&.original_exception),
            thrown_by: thrown_by&.index,
            thrown_exception: Utils.pretty_exception(thrown_by&.command_exception),
            runtime:
          }.compact
        end

        private

        def append_execution_result
          results.push(self).sort_by!(&:index)
        end

        def freeze_execution_objects
          context.freeze if index == 1
          freeze
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lite-command-3.3.2 lib/lite/command/internals/results.rb
lite-command-3.3.1 lib/lite/command/internals/results.rb