Module: Faraday::MiddlewareRegistry
- Included in:
- Adapter, Middleware, Request, Response
- Defined in:
- lib/faraday.rb
Instance Method Summary collapse
-
#lookup_middleware(key) ⇒ Object
Internal: Lookup middleware class with a registered Symbol shortcut.
-
#register_middleware(mapping) ⇒ Object
Internal: Register middleware class(es) on the current module.
Instance Method Details
#lookup_middleware(key) ⇒ Object
Internal: Lookup middleware class with a registered Symbol shortcut.
Returns a middleware Class.
62 63 64 65 66 67 68 |
# File 'lib/faraday.rb', line 62 def lookup_middleware(key) unless defined? @registered_middleware and found = @registered_middleware[key] raise "#{key.inspect} is not registered on #{self}" end found = @registered_middleware[key] = found.call if found.is_a? Proc found.is_a?(Module) ? found : const_get(found) end |
#register_middleware(mapping) ⇒ Object
Internal: Register middleware class(es) on the current module.
mapping - A Hash mapping Symbol keys to classes. See
Faraday.register_middleware for more details.
55 56 57 |
# File 'lib/faraday.rb', line 55 def register_middleware(mapping) (@registered_middleware ||= {}).update(mapping) end |