Sha256: 4c474e309178a475a8238f0f39f568d96ac0f1f5b6bbd35ae3f93855d6f4e63b

Contents?: true

Size: 685 Bytes

Versions: 2

Compression:

Stored size: 685 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

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

  def self.transitions(name: nil, desc: nil)
    Transitions.tracking.start(name: name, desc: desc)

    result = yield

    result.is_a?(::BCDD::Result) or raise Error::UnexpectedOutcome.build(outcome: result, origin: :transitions)

    Transitions.tracking.finish(result: result)

    result
  rescue ::Exception => e
    Transitions.tracking.reset!

    raise e
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bcdd-result-0.11.0 lib/bcdd/result/transitions.rb
bcdd-result-0.10.0 lib/bcdd/result/transitions.rb