Class: Faraday::Middleware
- Extended by:
- MiddlewareRegistry
- Defined in:
- lib/faraday/middleware.rb
Direct Known Subclasses
Adapter, Request::Authorization, Request::Retry, Request::UrlEncoded, Response::Middleware
Class Attribute Summary collapse
-
.load_error ⇒ Object
Returns the value of attribute load_error.
Class Method Summary collapse
-
.dependency(lib = nil) ⇒ Object
Executes a block which should try to require and reference dependent libraries.
- .inherited(subclass) ⇒ Object
- .loaded? ⇒ Boolean
- .new ⇒ Object
Instance Method Summary collapse
-
#initialize(app = nil) ⇒ Middleware
constructor
A new instance of Middleware.
Methods included from MiddlewareRegistry
lookup_middleware, register_middleware
Constructor Details
#initialize(app = nil) ⇒ Middleware
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
.load_error ⇒ Object
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
.dependency(lib = nil) ⇒ Object
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 |
.inherited(subclass) ⇒ Object
28 29 30 31 |
# File 'lib/faraday/middleware.rb', line 28 def self.inherited(subclass) super subclass.send(:load_error=, self.load_error) end |
.loaded? ⇒ Boolean
24 25 26 |
# File 'lib/faraday/middleware.rb', line 24 def self.loaded? load_error.nil? end |
.new ⇒ Object
19 20 21 22 |
# File 'lib/faraday/middleware.rb', line 19 def self.new(*) raise "missing dependency for #{self}: #{load_error.}" unless loaded? super end |