Sha256: ff6d8dea9ac190e879dd1bfb3d8bec1cafcc21817a26b855b52583320fcf592c

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

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, **opts, &block)
      if klass.is_a?(Class)
        middleware = klass
      else
        begin
          middleware = OmniAuth::Strategies.const_get(OmniAuth::Utils.camelize(klass.to_s).to_s, false)
        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

      use middleware, *args, **options.merge(opts), &block
    end

    def call(env)
      to_app.call(env)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
omniauth-2.1.2 lib/omniauth/builder.rb
omniauth-2.1.1 lib/omniauth/builder.rb
omniauth-2.1.0 lib/omniauth/builder.rb