1
0
Fork 0
mirror of https://github.com/omniauth/omniauth.git synced 2022-11-09 12:31:49 -05:00
omniauth--omniauth/lib/omniauth/builder.rb
Bobby McDonald c85c717f0d
Remove init code for builder
Now that rack is locked to > 1.6.2, we don't need all of this custom
logic in the builder initializer. Using a memoizer we can remove the
initial @options set.
2019-11-11 01:44:47 -05:00

48 lines
1.2 KiB
Ruby

module OmniAuth
class Builder < ::Rack::Builder
def on_failure(&block)
OmniAuth.config.on_failure = block
end
def before_options_phase(&block)
OmniAuth.config.before_options_phase = block
end
def before_request_phase(&block)
OmniAuth.config.before_request_phase = block
end
def before_callback_phase(&block)
OmniAuth.config.before_callback_phase = block
end
def configure(&block)
OmniAuth.configure(&block)
end
def options(options = false)
return @options ||= {} if options == false
@options = options
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).to_s)
rescue NameError
raise(LoadError.new("Could not find matching strategy for #{klass.inspect}. You may need to install an additional gem (such as omniauth-#{klass})."))
end
end
args.last.is_a?(Hash) ? args.push(options.merge(args.pop)) : args.push(options)
use middleware, *args, &block
end
def call(env)
to_app.call(env)
end
end
end