class Transloadit::Response

Public Class Methods

new(response) click to toggle source

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

[](attribute) click to toggle source

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
body() click to toggle source

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
extend!(mod) click to toggle source

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
inspect() click to toggle source

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

__getobj__() click to toggle source

The object to delegate method calls to.

@return [RestClient::Response]

# File lib/transloadit/response.rb, line 65
def __getobj__
  @response
end
__setobj__(response) click to toggle source

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
replace(other) click to toggle source

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