Sha256: 9022ca01826f19aa4a43825903a17a6dfb6fb9c463a8597fc0bdbd83b3ee75e4

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 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_hash
          {
            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
        alias to_h to_hash

        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

5 entries across 5 versions & 1 rubygems

Version Path
lite-command-3.3.0 lib/lite/command/internals/results.rb
lite-command-3.2.1 lib/lite/command/internals/results.rb
lite-command-3.2.0 lib/lite/command/internals/results.rb
lite-command-3.1.5 lib/lite/command/internals/results.rb
lite-command-3.1.4 lib/lite/command/internals/results.rb