Class: OmniAuth::Builder
- Inherits:
-
Rack::Builder
- Object
- Rack::Builder
- OmniAuth::Builder
- Defined in:
- lib/omniauth/builder.rb
Instance Method Summary collapse
- #before_callback_phase(&block) ⇒ Object
- #before_options_phase(&block) ⇒ Object
- #before_request_phase(&block) ⇒ Object
- #call(env) ⇒ Object
- #configure(&block) ⇒ Object
-
#initialize(app, &block) ⇒ Builder
constructor
A new instance of Builder.
- #on_failure(&block) ⇒ Object
- #options(options = false) ⇒ Object
- #provider(klass, *args, &block) ⇒ Object
- #rack14? ⇒ Boolean
- #rack2? ⇒ Boolean
Constructor Details
#initialize(app, &block) ⇒ Builder
Returns a new instance of Builder.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/omniauth/builder.rb', line 3 def initialize(app, &block) @options = nil if rack14? || rack2? super else @app = app super(&block) @ins << @app end end |
Instance Method Details
#before_callback_phase(&block) ⇒ Object
34 35 36 |
# File 'lib/omniauth/builder.rb', line 34 def before_callback_phase(&block) OmniAuth.config.before_callback_phase = block end |
#before_options_phase(&block) ⇒ Object
26 27 28 |
# File 'lib/omniauth/builder.rb', line 26 def (&block) OmniAuth.config. = block end |
#before_request_phase(&block) ⇒ Object
30 31 32 |
# File 'lib/omniauth/builder.rb', line 30 def before_request_phase(&block) OmniAuth.config.before_request_phase = block end |
#call(env) ⇒ Object
62 63 64 |
# File 'lib/omniauth/builder.rb', line 62 def call(env) to_app.call(env) end |
#configure(&block) ⇒ Object
38 39 40 |
# File 'lib/omniauth/builder.rb', line 38 def configure(&block) OmniAuth.configure(&block) end |
#on_failure(&block) ⇒ Object
22 23 24 |
# File 'lib/omniauth/builder.rb', line 22 def on_failure(&block) OmniAuth.config.on_failure = block end |
#options(options = false) ⇒ Object
42 43 44 45 |
# File 'lib/omniauth/builder.rb', line 42 def ( = false) return @options || {} if == false @options = end |
#provider(klass, *args, &block) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/omniauth/builder.rb', line 47 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(.merge(args.pop)) : args.push() use middleware, *args, &block end |
#rack14? ⇒ Boolean
14 15 16 |
# File 'lib/omniauth/builder.rb', line 14 def rack14? Rack.release.start_with?('1.') && (Rack.release.split('.')[1].to_i >= 4) end |
#rack2? ⇒ Boolean
18 19 20 |
# File 'lib/omniauth/builder.rb', line 18 def rack2? Rack.release.start_with? '2.' end |