Sha256: 90a71eb7c5443ec5ff7966a137f923f2595513e4b6252aad154afa3f82e7aed6
Contents?: true
Size: 1.04 KB
Versions: 7
Compression:
Stored size: 1.04 KB
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([]).with_index do |(command, results), i| command.call if command.respond_to?(:errors) && command.failure? failed_steps << failed_step(i, command) 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 failed_steps @failed_steps ||= [] end def steps @steps ||= @args.flatten end private def failed_step(index, command) { index: index, step: index + 1, name: command.class.name, args: command.args, errors: command&.errors&.full_messages } end end end end
Version data entries
7 entries across 7 versions & 1 rubygems