Sha256: bda1e3ecaa43892fe93eef191c844a9be636e3105ae448408c3568711ef27670

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module Muina
  class Action
    class Step < Value
      # Commands are meant to run code with side effects and return no value.
      class Command < self
        def call(action = Object.new)
          return if action.instance_variable_get(:@__failure__)

          case result = Muina::Result() { action.instance_eval(&step) }
          when Muina::Result::Success then success
          when Muina::Result::Failure then failure(action, result)
          else nil
          end
        end

        private

        def success
          # noop
        end

        def failure(action, result)
          action.instance_variable_set(:@__failure__, result)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
muina-0.2.7 lib/muina/action/step/command.rb