class Tickethub::Response
Attributes
body[R]
headers[R]
parser[R]
response[R]
Public Class Methods
new(response, parser = nil)
click to toggle source
# File lib/tickethub/response.rb, line 5 def initialize(response, parser = nil) @response = response @body = response.body @headers = Headers.new(response.to_hash) @format = Formats.for(headers.content_type) @parser ||= @format && @format.new end
Public Instance Methods
as_json()
click to toggle source
# File lib/tickethub/response.rb, line 13 def as_json decoded end
code()
click to toggle source
# File lib/tickethub/response.rb, line 21 def code response.code.to_i end
Also aliased as: status
decoded()
click to toggle source
# File lib/tickethub/response.rb, line 27 def decoded @decoded ||= parser ? parser.decode(body) : body end
respond_to?(name)
click to toggle source
Calls superclass method
# File lib/tickethub/response.rb, line 31 def respond_to?(name) super || decoded.respond_to?(name) || response.respond_to?(name) end
to_json(*)
click to toggle source
# File lib/tickethub/response.rb, line 17 def to_json(*) as_json.to_json end
Protected Instance Methods
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/tickethub/response.rb, line 37 def method_missing(name, *args, &block) if decoded.respond_to?(name) decoded.send(name, *args, &block) elsif response.respond_to?(name) response.send(name, *args, &block) else super end end