Sha256: 407ce1d1ee847f53ad65a5edb51ea330fcdc1f2f6c1f4a87291d50944bb5cdaa

Contents?: true

Size: 909 Bytes

Versions: 9

Compression:

Stored size: 909 Bytes

Contents

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

      def initialize(call, value)
        @call, @value = call, 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

          fail 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

9 entries across 9 versions & 1 rubygems

Version Path
celluloid-essentials-0.20.5 lib/celluloid/internals/responses.rb
celluloid-essentials-0.20.2.1 lib/celluloid/internals/responses.rb
celluloid-essentials-0.20.2 lib/celluloid/internals/responses.rb
celluloid-essentials-0.20.1.1 lib/celluloid/internals/responses.rb
celluloid-essentials-0.20.1 lib/celluloid/internals/responses.rb
celluloid-essentials-0.20.0 lib/celluloid/internals/responses.rb
celluloid-essentials-0.20.0.pre17 lib/celluloid/internals/responses.rb
celluloid-essentials-0.20.0.pre16 lib/celluloid/internals/responses.rb
celluloid-essentials-0.20.0.pre15 lib/celluloid/internals/responses.rb