Module: Metaractor::FailureOutput

Defined in:
lib/metaractor/failure_output.rb

Instance Method Summary collapse

Instance Method Details

#to_sObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/metaractor/failure_output.rb', line 3

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.except(:errors))
  str
end