Sha256: db418ca2eab275571257607bbca8fe84fa476843de9cc8a7f7c02d603432d84b

Contents?: true

Size: 574 Bytes

Versions: 2

Compression:

Stored size: 574 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module Muina
  class Action
    class Step < Value
      # Failures wrap the result into the Failure side of the Result Monad and won't run if result is already set
      class Failure < self
        def call(action = nil)
          return if action.instance_variable_get(:@__result__) || !action.instance_variable_get(:@__failure__)

          result = Muina::Failure(Muina::Result() { action.instance_eval(&step) }.value!)
          action.instance_variable_set(:@__failure__, result)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
muina-0.2.8 lib/muina/action/step/failure.rb
muina-0.2.7 lib/muina/action/step/failure.rb