Sha256: be2ed1b8ba24ce70777b4161979f22d82da90f3f896d07178c529694d274b605

Contents?: true

Size: 516 Bytes

Versions: 4

Compression:

Stored size: 516 Bytes

Contents

module PipeRpc
  class Hub::Socket
    class Incoming
      def initialize(payload)
        @payload = payload
      end

      def to_h
        @hash ||= JSON.load(@payload).symbolize_keys.tap do |hash|
          hash[:error] = hash[:error].symbolize_keys if hash[:error]
          hash[:error][:data] = hash[:error][:data].symbolize_keys if hash[:error] and hash[:error][:data]
        end
      end

      def trigger(callbacks)
        callbacks.each{ |callback| callback.call(to_h) }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pipe_rpc-1.1.2 lib/pipe_rpc/hub_socket_incoming.rb
pipe_rpc-1.1.1 lib/pipe_rpc/hub_socket_incoming.rb
pipe_rpc-1.1.0 lib/pipe_rpc/hub_socket_incoming.rb
pipe_rpc-1.0.0 lib/pipe_rpc/hub_socket_incoming.rb