Sha256: 8da353c03add884024b4cb98f5c322c25b5d209ffa632fd24480dbe783b57a8d

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 command.respond_to?(:errors) && command.failure?
            merge_errors!(command) if respond_to?(:errors)
            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.1 lib/lite/command/procedure.rb