Sha256: f29c045179032dc8d9e0506d1edd14dd0e75b33323b3297059d37de4b7dcaa0e
Contents?: true
Size: 752 Bytes
Versions: 4
Compression:
Stored size: 752 Bytes
Contents
# frozen_string_literal: true require 'ostruct' module BusinessPipeline class Context < OpenStruct def self.build(context = {}) context.is_a?(self) ? context : new(context) end def initialize(*) super @failure = false end def fail @failure = true end def fail!(additional_context = {}) update!(additional_context) self.fail throw :early_stop, self end def failure? !!@failure end def succeed!(additional_context = {}) update!(additional_context) throw :early_stop, self end def success? !failure? end private def update!(context) context.each { |key, value| modifiable[key.to_sym] = value } end end end
Version data entries
4 entries across 4 versions & 1 rubygems