Sha256: 0734b32147bfd1ecb294ef414c1d74612725043dfc549af56860556b1f4a71f8

Contents?: true

Size: 1.61 KB

Versions: 6785

Compression:

Stored size: 1.61 KB

Contents

require 'typhoeus/response/header'
require 'typhoeus/response/informations'
require 'typhoeus/response/status'
require 'typhoeus/response/cacheable'

module Typhoeus

  # This class represents the response.
  class Response
    include Response::Informations
    include Response::Status
    include Response::Cacheable

    # Remembers the corresponding request.
    #
    # @example Get request.
    #   request = Typhoeus::Request.new("www.example.com")
    #   response = request.run
    #   request == response.request
    #   #=> true
    #
    # @return [ Typhoeus::Request ]
    attr_accessor :request

    # The provided options, which contain all the
    # informations about the request.
    #
    # @return [ Hash ]
    attr_accessor :options

    # Set the handled response.
    attr_writer :handled_response

    # @api private
    attr_writer :mock

    # Create a new response.
    #
    # @example Create a response.
    #  Response.new
    #
    # @param [ Hash ] options The options hash.
    #
    # @return [ Response ] The new response.
    def initialize(options = {})
      @options = options
      @headers = Header.new(options[:headers]) if options[:headers]
    end

    # Returns whether this request is mocked
    # or not.
    #
    # @api private
    def mock
      defined?(@mock) ? @mock : options[:mock]
    end
    alias :mock? :mock

    # Returns the handled_response if it has
    # been defined; otherwise, returns the response
    #
    # @return [ Object ] The result of callbacks
    #   done on the response or the original response.
    def handled_response
      @handled_response || self
    end
  end
end

Version data entries

6,785 entries across 6,782 versions & 24 rubygems

Version Path
cybrid_api_id_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_organization_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_bank_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_organization_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_id_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_bank_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_id_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_organization_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
ory-client-1.15.17 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_bank_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_organization_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_id_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_organization_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_bank_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_id_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_organization_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_bank_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_id_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_bank_ruby-0.123.111 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb
cybrid_api_organization_ruby-0.123.111 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/response.rb