Sha256: 53cb9e247d7aa0dfbf6c1eefc73fd3a419aab034b3630ed0b96d933e50fe3d9f

Contents?: true

Size: 1.53 KB

Versions: 16

Compression:

Stored size: 1.53 KB

Contents

module OmniAuth
  class Builder < ::Rack::Builder
    def initialize(app, &block)
      @options = nil
      if rack14? || rack2?
        super
      else
        @app = app
        super(&block)
        @ins << @app
      end
    end

    def rack14?
      Rack.release.start_with?('1.') && (Rack.release.split('.')[1].to_i >= 4)
    end

    def rack2?
      Rack.release.start_with? '2.'
    end

    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

Version data entries

16 entries across 15 versions & 2 rubygems

Version Path
tdiary-5.0.8 vendor/bundle/gems/omniauth-1.8.1/lib/omniauth/builder.rb
omniauth-1.8.1 lib/omniauth/builder.rb
omniauth-1.8.0 lib/omniauth/builder.rb
omniauth-1.4.3 lib/omniauth/builder.rb
omniauth-1.7.1 lib/omniauth/builder.rb
omniauth-1.7.0 lib/omniauth/builder.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/omniauth-1.6.1/lib/omniauth/builder.rb
tdiary-5.0.5 vendor/bundle/gems/omniauth-1.6.1/lib/omniauth/builder.rb
tdiary-5.0.4 vendor/bundle/gems/omniauth-1.6.1/lib/omniauth/builder.rb
omniauth-1.6.1 lib/omniauth/builder.rb
omniauth-1.6.0 lib/omniauth/builder.rb
omniauth-1.5.0 lib/omniauth/builder.rb
omniauth-1.4.2 lib/omniauth/builder.rb
omniauth-1.4.1 lib/omniauth/builder.rb
omniauth-1.4.0 lib/omniauth/builder.rb
omniauth-1.3.2 lib/omniauth/builder.rb