Sha256: 5dcfd74de44e852862e70d5f8f88aee7a800093f4092efc2ff09c4527cef4735
Contents?: true
Size: 1021 Bytes
Versions: 4
Compression:
Stored size: 1021 Bytes
Contents
module PipeRpc class Hub class Message def initialize(hub, message) @hub = hub @message = message end def notification? @message.has_key? :method and not id? end def request? @message.has_key? :method and id? end def response? (result? or error_message?) and id? end def error? error_message? and not id? end def handler @handler ||= type.new(@message) rescue => e @hub.send_response ErrorResponse.new(id: nil, error: { code: -32600, data: { message: e.message } }) nil end private def result? @message.has_key? :result end def error_message? @message.has_key? :error end def type if error_message? ErrorResponse elsif result? ResultResponse else Request end end def id? not @message[:id].nil? end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
pipe_rpc-0.3.2 | lib/pipe_rpc/hub/message.rb |
pipe_rpc-0.3.1 | lib/pipe_rpc/hub/message.rb |
pipe_rpc-0.3.0 | lib/pipe_rpc/hub/message.rb |
pipe_rpc-0.2.2 | lib/pipe_rpc/hub/message.rb |