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