Sha256: 01888747be85ca27b8cb3d743a95a9a0fa99a96e877646afcb511addedae8c80

Contents?: true

Size: 1.31 KB

Versions: 6819

Compression:

Stored size: 1.31 KB

Contents

module Typhoeus
  class Request

    # This module handles the blocked connection request mode on
    # the request side, where only stubbed requests
    # are allowed.
    # Connection blocking needs to be turned on:
    #   Typhoeus.configure do |config|
    #     config.block_connection = true
    #   end
    #
    # When trying to do real requests a NoStub error
    # is raised.
    #
    # @api private
    module BlockConnection

      # Overrides run in order to check before if block connection
      # is turned on. If thats the case a NoStub error is
      # raised.
      #
      # @example Run request.
      #   request.run
      #
      # @raise [Typhoeus::Errors::NoStub] If connection is blocked
      #   and no stub defined.
      def run
        if blocked?
          raise Typhoeus::Errors::NoStub.new(self)
        else
          super
        end
      end

      # Returns wether a request is blocked or not. Takes
      # request.block_connection and Typhoeus::Config.block_connection
      # into consideration.
      #
      # @example Blocked?
      #   request.blocked?
      #
      # @return [ Boolean ] True if blocked, false else.
      def blocked?
        if block_connection.nil?
          Typhoeus::Config.block_connection
        else
          block_connection
        end
      end
    end
  end
end

Version data entries

6,819 entries across 6,816 versions & 27 rubygems

Version Path
cybrid_api_bank_ruby-0.123.149 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
cybrid_api_id_ruby-0.123.149 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
cybrid_api_organization_ruby-0.123.149 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
cybrid_api_bank_ruby-0.123.148 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
cybrid_api_id_ruby-0.123.148 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
cybrid_api_organization_ruby-0.123.148 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
cybrid_api_bank_ruby-0.123.147 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
cybrid_api_organization_ruby-0.123.147 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
cybrid_api_id_ruby-0.123.147 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
ory-client-1.16.2 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
talon_one-7.0.0 .github/.example/vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
cybrid_api_bank_ruby-0.123.145 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
cybrid_api_organization_ruby-0.123.145 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
cybrid_api_id_ruby-0.123.145 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
cybrid_api_bank_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
cybrid_api_id_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
cybrid_api_organization_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
ory-client-1.16.1 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
ory-client-1.16.0 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb
cybrid_api_bank_ruby-0.123.143 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/block_connection.rb