omniauth--omniauth/lib/omniauth/builder.rb

32 lines
738 B
Ruby
Raw Normal View History

require 'omniauth'
2011-09-03 18:08:07 +00:00
module OmniAuth
class Builder < ::Rack::Builder
def on_failure(&block)
OmniAuth.config.on_failure = block
end
def configure(&block)
OmniAuth.configure(&block)
end
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
2011-09-03 18:08:07 +00:00
end
use middleware, *args, &block
end
def call(env)
to_app.call(env)
end
end
end