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.



7
8
9
10
11
# File 'lib/mauth/middleware.rb', line 7

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



18
19
20
21
22
23
# File 'lib/mauth/middleware.rb', line 18

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