Sha256: 35ecd768e8ad29d7f53d6b574ab1c35c222ce6fe53eb197ff32bd1d8b733824d

Contents?: true

Size: 671 Bytes

Versions: 1

Compression:

Stored size: 671 Bytes

Contents

# frozen_string_literal: true

class BCDD::Result
  module Transitions
    require_relative 'transitions/tree'
    require_relative 'transitions/tracking'

    THREAD_VAR_NAME = :bcdd_result_transitions_tracking

    EnsureResult = ->(result) do
      return result if result.is_a?(::BCDD::Result)

      raise Error::UnexpectedOutcome.build(outcome: result, origin: :transitions)
    end

    def self.tracking
      Thread.current[THREAD_VAR_NAME] ||= Tracking.instance
    end
  end

  def self.transitions(name: nil, desc: nil, &block)
    Transitions.tracking.exec(name, desc, &block)
  rescue ::Exception => e
    Transitions.tracking.reset!

    raise e
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bcdd-result-0.12.0 lib/bcdd/result/transitions.rb