Sha256: e9e22ca176c66d127c2cf57fd3ea52fde97bebf43b55f1bfa759f28c65e4e210
Contents?: true
Size: 989 Bytes
Versions: 1
Compression:
Stored size: 989 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_error(id: nil, 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pipe_rpc-0.2.0 | lib/pipe_rpc/hub/message.rb |