Class: Faraday::Middleware

Inherits:
Object show all
Extended by:
MiddlewareRegistry
Defined in:
lib/faraday/middleware.rb

Direct Known Subclasses

Adapter, Request::BasicAuthentication, Request::Retry, Request::TokenAuthentication, Request::UrlEncoded, Response::Middleware

Class Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from MiddlewareRegistry

lookup_middleware, register_middleware

Constructor Details

- (Middleware) initialize(app = nil)

Returns a new instance of Middleware



33
34
35
# File 'lib/faraday/middleware.rb', line 33

def initialize(app = nil)
  @app = app
end

Class Attribute Details

+ (Object) load_error

Returns the value of attribute load_error



6
7
8
# File 'lib/faraday/middleware.rb', line 6

def load_error
  @load_error
end

Class Method Details

+ (Object) dependency(lib = nil)

Executes a block which should try to require and reference dependent libraries



13
14
15
16
17
# File 'lib/faraday/middleware.rb', line 13

def self.dependency(lib = nil)
  lib ? require(lib) : yield
rescue LoadError, NameError => error
  self.load_error = error
end

+ (Object) inherited(subclass)



28
29
30
31
# File 'lib/faraday/middleware.rb', line 28

def self.inherited(subclass)
  super
  subclass.send(:load_error=, self.load_error)
end

+ (Boolean) loaded?

Returns:

  • (Boolean)


24
25
26
# File 'lib/faraday/middleware.rb', line 24

def self.loaded?
  load_error.nil?
end

+ (Object) new



19
20
21
22
# File 'lib/faraday/middleware.rb', line 19

def self.new(*)
  raise "missing dependency for #{self}: #{load_error.message}" unless loaded?
  super
end