Sha256: 7b055115793f32239358047c23685934380bb50f7563c9746752ac8e004bb3a9

Contents?: true

Size: 945 Bytes

Versions: 8

Compression:

Stored size: 945 Bytes

Contents

# ApiClient::Dispatcher provides methods to make requests
module ApiClient::Dispatcher
  autoload :Typhoeus, 'api-client/dispatcher/typhoeus'
  autoload :NetHttp, 'api-client/dispatcher/net-http'

  def self.method_missing(method_name, *args)
    if defined?(::Typhoeus)
      return Typhoeus.send(method_name, *args) if Typhoeus.respond_to?(method_name)
    else
      return NetHttp.send(method_name, *args) if NetHttp.respond_to?(method_name)
    end
    super
  end

  # Overwrite respond_to? default behavior
  #
  # @param [Symbol] method_name the name of the method.
  # @param [Boolean] include_private if it does work to private methods as well.
  # @return [Boolean] if it responds to the method or not.
  def self.respond_to_missing?(method_name, include_private = false)
    if defined?(::Typhoeus)
      return true if Typhoeus.respond_to?(method_name)
    end
    return true if NetHttp.respond_to?(method_name)
    super
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
api-client-2.4.0 lib/api-client/dispatcher.rb
api-client-2.3.0 lib/api-client/dispatcher.rb
api-client-2.2.0 lib/api-client/dispatcher.rb
api-client-2.1.0 lib/api-client/dispatcher.rb
api-client-2.0.3 lib/api-client/dispatcher.rb
api-client-2.0.2 lib/api-client/dispatcher.rb
api-client-2.0.1 lib/api-client/dispatcher.rb
api-client-2.0.0 lib/api-client/dispatcher.rb