Sha256: 7d1506ba90a05e49cb2033d24f34978e0687b00872ee96683eb1224dd2b58d72

Contents?: true

Size: 640 Bytes

Versions: 6

Compression:

Stored size: 640 Bytes

Contents

module Metaractor
  module FailureOutput
    def to_s
      str = ''

      if !context.errors.empty?
        str << "Errors:\n"
        str << Metaractor.format_hash(context.errors.to_h)
        str << "\n\n"
      end

      if !context._called.empty?
        str << "Previously Called:\n"
        context._called.each do |interactor|
          str << interactor.class.name.to_s
          str << "\n"
        end
        str << "\n"
      end

      str << "Context:\n"
      str << Metaractor.format_hash(context.to_h.reject{|k,_| k == :errors})
      str
    end
  end
end

Interactor::Failure.send(:include, Metaractor::FailureOutput)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
metaractor-3.3.0 lib/metaractor/failure_output.rb
metaractor-3.2.0 lib/metaractor/failure_output.rb
metaractor-3.1.1 lib/metaractor/failure_output.rb
metaractor-3.1.0 lib/metaractor/failure_output.rb
metaractor-3.0.1 lib/metaractor/failure_output.rb
metaractor-3.0.0 lib/metaractor/failure_output.rb