Module Faraday::MiddlewareRegistry
In: lib/faraday.rb

Public: Adds the ability for other modules to register and lookup middleware classes.

Methods

Public Instance methods

Public: Lookup middleware class with a registered Symbol shortcut.

key - The Symbol key for the registered middleware.

Examples

  module Faraday
    class Whatever
      register_middleware :foo => Foo
    end
  end

  Faraday::Whatever.lookup_middleware(:foo)
  # => Faraday::Whatever::Foo

Returns a middleware Class.

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

mapping - A Hash mapping Symbol keys to classes. Classes can be expressed

          as fully qualified constant, or a Proc that will be lazily
          called to return the former.

Examples

  module Faraday
    class Whatever
      # Middleware looked up by :foo returns Faraday::Whatever::Foo.
      register_middleware :foo => Foo

      # Middleware looked up by :bar returns Faraday::Whatever.const_get(:Bar)
      register_middleware :bar => :Bar

      # Middleware looked up by :baz requires 'baz' and returns Faraday::Whatever.const_get(:Baz)
      register_middleware :baz => [:Baz, 'baz']
    end
  end

Returns nothing.

[Validate]