Sha256: 8a2f18e00165e494193cf7a6bff168a7b3e0a01edca3687cd6ac2a086137494a
Contents?: true
Size: 896 Bytes
Versions: 1
Compression:
Stored size: 896 Bytes
Contents
module Metaractor module FailureOutput def self.format_hash(hash) if @hash_formatter.nil? @hash_formatter = ->(hash){ hash.inspect } end @hash_formatter.call(hash) end def self.hash_formatter=(callable) @hash_formatter = callable end def to_s str = '' if !context.errors.empty? str << "Errors:\n" str << Metaractor::FailureOutput.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 end str << "\n\n" end str << "Context:\n" str << Metaractor::FailureOutput.format_hash(context.to_h.reject{|k,_| k == :errors}) str end end end Interactor::Failure.send(:include, Metaractor::FailureOutput)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
metaractor-2.1.0 | lib/metaractor/failure_output.rb |