Module: Faraday::MiddlewareRegistry
- Included in:
- Adapter, Middleware, Request, Response
- Defined in:
- lib/faraday/middleware_registry.rb
Overview
Adds the ability for other modules to register and lookup middleware classes.
Instance Method Summary collapse
-
#lookup_middleware(key) ⇒ Class
Lookup middleware class with a registered Symbol shortcut.
-
#register_middleware(**mappings) ⇒ void
Register middleware class(es) on the current module.
- #registered_middleware ⇒ Object
-
#unregister_middleware(key) ⇒ Object
Unregister a previously registered middleware class.
Instance Method Details
#lookup_middleware(key) ⇒ Class
Lookup middleware class with a registered Symbol shortcut.
55 56 57 58 |
# File 'lib/faraday/middleware_registry.rb', line 55 def lookup_middleware(key) load_middleware(key) || raise(Faraday::Error, "#{key.inspect} is not registered on #{self}") end |
#register_middleware(**mappings) ⇒ void
This method returns an undefined value.
Register middleware class(es) on the current module.
26 27 28 29 30 |
# File 'lib/faraday/middleware_registry.rb', line 26 def register_middleware(**mappings) middleware_mutex do registered_middleware.update(mappings) end end |
#registered_middleware ⇒ Object
9 10 11 |
# File 'lib/faraday/middleware_registry.rb', line 9 def registered_middleware @registered_middleware ||= {} end |
#unregister_middleware(key) ⇒ Object
Unregister a previously registered middleware class.
35 36 37 |
# File 'lib/faraday/middleware_registry.rb', line 35 def unregister_middleware(key) registered_middleware.delete(key) end |