Sha256: b0f3dfefab1ba763c15b6ce7dd58a3b94dd0218d809ba0e099a2d532c6faddb7

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Lite
  module Command
    module Internals
      module Faults

        def self.included(base)
          base.class_eval { attr_reader :command_exception, :original_exception }
        end

        def caused_by
          return if success?

          @caused_by || self
        end

        def caused_fault?
          caused_by == self
        end

        def thrown_by
          return if success?

          @thrown_by || self
        end

        def threw_fault?
          thrown_by == self
        end

        def thrown?
          fault? && !caused_fault?
        end

        def raise!(original: false)
          exception = (command_exception unless original) || original_exception
          return if exception.nil?

          raise(exception)
        end

        private

        def throw!(command)
          return if command.success?

          send(:"#{command.status}!", command)
        end

        def raise_dynamic_faults?
          Lite::Command.configuration.raise_dynamic_faults
        end

      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lite-command-3.3.3 lib/lite/command/internals/faults.rb
lite-command-3.3.2 lib/lite/command/internals/faults.rb
lite-command-3.3.1 lib/lite/command/internals/faults.rb
lite-command-3.3.0 lib/lite/command/internals/faults.rb
lite-command-3.2.1 lib/lite/command/internals/faults.rb
lite-command-3.2.0 lib/lite/command/internals/faults.rb
lite-command-3.1.5 lib/lite/command/internals/faults.rb
lite-command-3.1.4 lib/lite/command/internals/faults.rb