Class: HTTPI::Adapter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/httpi/adapter/base.rb

Overview

HTTPI::Adapter::Base

Allows you to build your own adapter by implementing all public instance methods. Register your adapter by calling the base class' .register method.

Direct Known Subclasses

Curb, EmHttpRequest, Excon, HTTP, HTTPClient, NetHTTP, Rack

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Base

Returns a new instance of Base.


18
19
# File 'lib/httpi/adapter/base.rb', line 18

def initialize(request)
end

Class Method Details

.register(name, options = {}) ⇒ Object

Registers an adapter.


13
14
15
16
# File 'lib/httpi/adapter/base.rb', line 13

def self.register(name, options = {})
  deps = options.fetch(:deps, [])
  Adapter.register(name, self, deps)
end

Instance Method Details

#clientObject

Returns a client instance.


22
23
24
# File 'lib/httpi/adapter/base.rb', line 22

def client
  raise NotImplementedError, "Adapters need to implement a #client method"
end

#request(method) ⇒ Object

Executes arbitrary HTTP requests.

Raises:

See Also:


28
29
30
# File 'lib/httpi/adapter/base.rb', line 28

def request(method)
  raise NotImplementedError, "Adapters need to implement a #request method"
end