Sha256: f4889e873accab4e8d6111cc9ace1b30421ae3e56e6a81f6c1f85d3a89c45f1b

Contents?: true

Size: 918 Bytes

Versions: 2

Compression:

Stored size: 918 Bytes

Contents

module Celluloid
  module Internals
    # Responses to calls
    class Response
      attr_reader :call, :value

      def initialize(call, value)
        @call = call
        @value = value
      end

      def dispatch
        @call.task.resume self
      end

      # Call completed successfully
      class Success < Response; end

      # Call was aborted due to sender error
      class Error < Response
        def value
          ex = super
          ex = ex.cause if ex.is_a? Celluloid::AbortError

          if ex.backtrace
            ex.backtrace << "(celluloid):0:in `remote procedure call'"
            ex.backtrace.concat(caller)
          end

          raise ex
        end
      end

      class Block
        def initialize(call, result)
          @call = call
          @result = result
        end

        def dispatch
          @call.task.resume(@result)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
celluloid-0.18.0 lib/celluloid/internals/responses.rb
celluloid-0.18.0.pre2 lib/celluloid/internals/responses.rb