Class: OmniAuth::Builder

Inherits:
Rack::Builder
  • Object
show all
Defined in:
lib/omniauth/builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, &block) ⇒ Builder

Returns a new instance of Builder.



5
6
7
8
# File 'lib/omniauth/builder.rb', line 5

def initialize(app, &block)
  @app = app
  super(&block)
end

Instance Method Details

#call(env) ⇒ Object



32
33
34
35
# File 'lib/omniauth/builder.rb', line 32

def call(env)
  @ins << @app unless @ins.include?(@app)
  to_app.call(env)
end

#configure(&block) ⇒ Object



14
15
16
# File 'lib/omniauth/builder.rb', line 14

def configure(&block)
  OmniAuth.configure(&block)
end

#on_failure(&block) ⇒ Object



10
11
12
# File 'lib/omniauth/builder.rb', line 10

def on_failure(&block)
  OmniAuth.config.on_failure = block
end

#provider(klass, *args, &block) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/omniauth/builder.rb', line 18

def provider(klass, *args, &block)
  if klass.is_a?(Class)
    middleware = klass
  else
    begin
      middleware = OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(klass.to_s)}")
    rescue NameError
      raise LoadError, "Could not find matching strategy for #{klass.inspect}. You may need to install an additional gem (such as omniauth-#{klass})."
    end
  end

  use middleware, *args, &block
end