Class: MAuth::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/mauth/middleware.rb

Overview

base class for middleware, common to both Faraday and Rack

Instance Method Summary collapse

Constructor Details

#initialize(app, config = {}) ⇒ Middleware

Returns a new instance of Middleware.



5
6
7
8
9
# File 'lib/mauth/middleware.rb', line 5

def initialize(app, config = {})
  @app = app
  # stringify symbol keys
  @config = config.stringify_symbol_keys
end

Instance Method Details

#mauth_clientObject

returns a MAuth::Client - if one was given as ‘mauth_client’ when initializing the middleware, then that one; otherwise the configurationg given to initialize the middleware is passed along to make a new MAuth::Client.

this method may be overloaded to provide more flexibility in providing a MAuth::Client



16
17
18
19
20
21
# File 'lib/mauth/middleware.rb', line 16

def mauth_client
  require 'mauth/client'
  # @_mauth_client ivar only used here for caching; should not be used by other methods, in
  # order that overloading #mauth_client will work
  @_mauth_client ||= @config['mauth_client'] || MAuth::Client.new(@config)
end