Sha256: 3aed3d38a4360b65cac3582ec240f4cdb188c3c8d406869e2e211877cc2c3068

Contents?: true

Size: 655 Bytes

Versions: 2

Compression:

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

      def safely(&)
        send_message(:perform_safely, &)
        nil
      end

      def within_actor? = true

      def stop = nil

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

Version data entries

2 entries across 2 versions & 1 rubygems

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