Sha256: 54258f48f506e86263b893ac1e80001272fd401ff2a58600d9c7fe08b6fd36a2
Contents?: true
Size: 618 Bytes
Versions: 4
Compression:
Stored size: 618 Bytes
Contents
module PipeRpc class ResultResponse def initialize(args = {}) @result = sanitize(args.fetch(:result)) @id = args.fetch(:id) end attr_reader :result, :id def to_h { id: id, result: result } end private def sanitize(result) if true == result or false == result or nil == result or result.is_a?(String) or result.is_a?(Numeric) result elsif result.is_a?(Array) result.map{ |v| sanitize(v) } elsif result.is_a?(Hash) Hash[result.map{ |k,v| [sanitize(k), sanitize(v)] }] else result.to_s end end end end
Version data entries
4 entries across 4 versions & 1 rubygems