Sha256: 726644c9b5f22a7add92fa46b064e573f798c73219b8f72602ea16c58fab8b61

Contents?: true

Size: 685 Bytes

Versions: 1

Compression:

Stored size: 685 Bytes

Contents

# frozen_string_literal: true

module Lite
  module Command
    class Procedure < Complex

      include Lite::Command::Extensions::Errors

      attr_accessor :exit_on_failure

      def execute
        steps.each_with_object([]) do |command, results|
          command.call

          if respond_to?(:errors) && command.respond_to?(:errors) && command.failure?
            merge_errors!(command)
            break results if exit_on_failure?
          else
            results << command.result
          end
        end
      end

      def exit_on_failure?
        @exit_on_failure ||= false
      end

      def steps
        @steps ||= @args.flatten
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lite-command-1.1.0 lib/lite/command/procedure.rb