Module: Faraday::MiddlewareRegistry

Included in:
Adapter, Middleware, Request, Response
Defined in:
lib/faraday.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) lookup_middleware(key)

Internal: Lookup middleware class with a registered Symbol shortcut.

Returns a middleware Class.



48
49
50
51
52
53
54
# File 'lib/faraday.rb', line 48

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

- (Object) register_middleware(mapping)

Internal: Register middleware class(es) on the current module.

mapping - A Hash mapping Symbol keys to classes. See

Faraday.register_middleware for more details.


41
42
43
# File 'lib/faraday.rb', line 41

def register_middleware(mapping)
  (@registered_middleware ||= {}).update(mapping)
end