class Transloadit::Response
Public Class Methods
Creates an enhanced response wrapped around a RestClient response.
@param [RestClient::Response] response the JSON response to wrap
# File lib/transloadit/response.rb, line 14 def initialize(response) self.__setobj__(response) end
Public Instance Methods
Returns the attribute from the JSON response.
@param [String] attribute the attribute name to look up @return [String] the value for the attribute
# File lib/transloadit/response.rb, line 24 def [](attribute) self.body[attribute.to_s] end
Returns the parsed JSON body.
@return [Hash] the parsed JSON body hash
# File lib/transloadit/response.rb, line 33 def body MultiJson.load self.__getobj__.body end
Chainably extends the response with additional methods. Used to add context-specific functionality to a response.
@param [Module] mod the module to extend with @return [Transloadit::Response] the extended response
# File lib/transloadit/response.rb, line 53 def extend!(mod) self.extend(mod) self end
Inspects the body of the response.
@return [String] a human-readable version of the body
# File lib/transloadit/response.rb, line 42 def inspect self.body.inspect end
Protected Instance Methods
The object to delegate method calls to.
@return [RestClient::Response]
# File lib/transloadit/response.rb, line 65 def __getobj__ @response end
Sets the object to delegate method calls to.
@param [RestClient::Response] response the response to delegate to @return [RestClient::Response] the delegated response
# File lib/transloadit/response.rb, line 75 def __setobj__(response) @response = response end
Replaces the object this instance delegates to with the one the other object uses.
@param [Delegator] other the object whose delegate to use @return [Transloadit::Response] this response
# File lib/transloadit/response.rb, line 86 def replace(other) self.__setobj__ other.__getobj__ self end