Sha256: b4fb849e552b0db2f6bf42a9173fe3440018e59020e3fc0cd4026c8c441b0fb0
Contents?: true
Size: 986 Bytes
Versions: 1
Compression:
Stored size: 986 Bytes
Contents
# typed: strict # frozen_string_literal: true module Muina class Action class Step < Value # Queries are meant to run side effect free code and return the resulting value wrapped in a Result::Success class Query < self const :name, Symbol def call(action = Object.new) # rubocop:disable Metrics/MethodLength return if action.instance_variable_get(:@__failure__) case result = Muina::Result() { action.instance_eval(&step) } when Muina::Result::Success then success(action, result) when Muina::Result::Failure then failure(action, result) # :nocov: else T.absurd(result) # :nocov: end end private def success(action, result) action.instance_variable_set("@#{name}", result.value!) 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.8 | lib/muina/action/step/query.rb |