Sha256: 3a7d664115510b8b73b077a2d4bf4f078d76ee30da0cf02b8878b56512ab045c
Contents?: true
Size: 739 Bytes
Versions: 1
Compression:
Stored size: 739 Bytes
Contents
module Metaractor class Error < StandardError; end class InvalidError < Error; end module Errors def self.included(base) base.class_eval do before :initialize_errors_array end end def initialize_errors_array context.errors ||= [] end def fail_with_error!(message:) add_error(message: message) context.fail! end def fail_with_errors!(messages:) add_errors(messages: messages) context.fail! end def add_error(message:) add_errors(messages: Array(message)) end def add_errors(messages:) context.errors ||= [] context.errors += messages end def error_messages context.errors.join("\n") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
metaractor-0.5.0 | lib/metaractor/errors.rb |