Class: Bones::RPC::Protocol::Response

Inherits:
Object
  • Object
show all
Includes:
AdapterHelper
Defined in:
lib/bones/rpc/protocol/response.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AdapterHelper

included, #receive_replies, #serialize

Constructor Details

#initialize(id, error, result) ⇒ Response

Returns a new instance of Response.


15
16
17
18
19
# File 'lib/bones/rpc/protocol/response.rb', line 15

def initialize(id, error, result)
  @id = id
  @error = error
  @result = result
end

Class Method Details

.map_from(object) ⇒ Object


38
39
40
41
42
43
44
45
# File 'lib/bones/rpc/protocol/response.rb', line 38

def self.map_from(object)
  message = allocate
  message.op_code = object[0]
  message.id = object[1]
  message.error = object[2]
  message.result = object[3]
  message
end

Instance Method Details

#get(node) ⇒ Object


47
48
49
# File 'lib/bones/rpc/protocol/response.rb', line 47

def get(node)
  node.detach(:request, id)
end

#log_inspectObject


27
28
29
30
31
32
33
34
35
36
# File 'lib/bones/rpc/protocol/response.rb', line 27

def log_inspect
  type = "RESPONSE"
  fields = []
  fields << ["%-12s", type]
  fields << ["id=%s", id]
  fields << ["error=%s", error]
  fields << ["result=%s", result]
  f, v = fields.transpose
  f.join(" ") % v
end

#op_codeObject


23
24
25
# File 'lib/bones/rpc/protocol/response.rb', line 23

def op_code
  @op_code ||= 1
end

#signal(future) ⇒ Object


51
52
53
# File 'lib/bones/rpc/protocol/response.rb', line 51

def signal(future)
  future.signal(FutureValue.new(self))
end