Class: Skein::RPC::Response

Inherits:
Base
  • Object
show all
Defined in:
lib/skein/rpc/response.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#id

Instance Method Summary collapse

Methods inherited from Base

#to_json

Constructor Details

#initialize(content = nil) ⇒ Response

Instance Methods =====================================================



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/skein/rpc/response.rb', line 9

def initialize(content = nil)
  case (content)
  when String
    data = Skein::Support.symbolize_keys(JSON.load(content))

    assign_from_hash!(data)
  when Hash
    assign_from_hash!(content)
  when nil
    self.id = SecureRandom.uuid
  else
    raise Skein::RPC::InvalidPayload, 'Invalid payload type: %s' % content.class
  end
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



5
6
7
# File 'lib/skein/rpc/response.rb', line 5

def error
  @error
end

#resultObject

Properties ===========================================================



4
5
6
# File 'lib/skein/rpc/response.rb', line 4

def result
  @result
end

Instance Method Details

#to_hObject



24
25
26
27
28
29
30
# File 'lib/skein/rpc/response.rb', line 24

def to_h
  {
    method: self.method,
    params: self.params,
    id: self.id
  }
end