Sha256: be0eeaf4cc969dd30aaa64f47c0d274a992dc0fd819f10d0e0be1616643435d1

Contents?: true

Size: 505 Bytes

Versions: 1

Compression:

Stored size: 505 Bytes

Contents

module Plumbing
  module Actor
    class Inline
      def initialize target
        @target = target
      end

      # Send the message to the target and wrap the result
      def send_message(message_name, *, &)
        value = @target.send(message_name, *, &)
        Result.new(value)
      rescue => ex
        Result.new(ex)
      end

      Result = Data.define(:value) do
        def await = value.is_a?(Exception) ? raise(value) : value
      end
      private_constant :Result
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
standard-procedure-plumbing-0.4.0 lib/plumbing/actor/inline.rb