Sha256: 35e439c0ba8f59bbeba50bf3bfd08d7c5beb323f7961060484e432b78a51ab7e
Contents?: true
Size: 1001 Bytes
Versions: 122
Compression:
Stored size: 1001 Bytes
Contents
module Tickethub class Response attr_reader :response, :body, :headers, :parser 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 def as_json decoded end def to_json(*) as_json.to_json end def code response.code.to_i end alias_method :status, :code def decoded @decoded ||= parser ? parser.decode(body) : body end def respond_to?(name) super || decoded.respond_to?(name) || response.respond_to?(name) end protected 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 end end require_relative 'response/headers'
Version data entries
122 entries across 122 versions & 1 rubygems