class GCR::Response
Attributes
body[R]
class_name[R]
Public Class Methods
from_hash(hash_resp)
click to toggle source
# File lib/gcr/response.rb, line 9 def self.from_hash(hash_resp) new( "class_name" => hash_resp["class_name"], "body" => hash_resp["body"], ) end
from_proto(proto_resp)
click to toggle source
# File lib/gcr/response.rb, line 2 def self.from_proto(proto_resp) new( "class_name" => proto_resp.class.name, "body" => proto_resp.to_json(emit_defaults: true) ) end
new(opts)
click to toggle source
# File lib/gcr/response.rb, line 18 def initialize(opts) @class_name = opts["class_name"] @body = opts["body"] end
Public Instance Methods
parsed_body()
click to toggle source
# File lib/gcr/response.rb, line 23 def parsed_body @parsed_body ||= JSON.decode(body) end
to_json(*_)
click to toggle source
# File lib/gcr/response.rb, line 27 def to_json(*_) JSON.dump("class_name" => class_name, "body" => body) end
to_proto()
click to toggle source
# File lib/gcr/response.rb, line 31 def to_proto Object.const_get(class_name).decode_json(body) end