class Phlanket::Response
The Response
class wraps HTTP responses
Attributes
payload_json[R]
Attribute reader for the original JSON payload string and JSON payload
Public Class Methods
new(json_string)
click to toggle source
A Blanket HTTP response wrapper. @param [String] json_string A string containing data in the JSON format @return [Blanket::Response] The wrapped Response
object
# File lib/phlanket/response.rb, line 12 def initialize(json_string) @payload_json = json_string || "{}" end
Private Instance Methods
method_missing(method, *args, &block)
click to toggle source
Allows accessing the payload's JSON keys through methods.
Calls superclass method
# File lib/phlanket/response.rb, line 19 def method_missing(method, *args, &block) if payload.respond_to? method payload.public_send method, *args, &block else super end end
payload()
click to toggle source
# File lib/phlanket/response.rb, line 27 def payload @payload ||= JSON.parse(payload_json, object_class: OpenStruct) end