Class: Negroni::OmniAuth::Config
- Inherits:
-
Object
- Object
- Negroni::OmniAuth::Config
- Defined in:
- lib/negroni/omniauth/config.rb
Overview
Config encapsulates OmniAuth configuration for Negroni
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#strategy ⇒ Symbol
The strategy for OmniAuth.
-
#strategy_class ⇒ Class
readonly
The class for the OmniAuth strategy.
-
#strategy_name ⇒ Object
readonly
Returns the value of attribute strategy_name.
Instance Method Summary collapse
-
#autoload_strategy ⇒ Object
Autoload a strategy.
-
#find_strategy ⇒ Object
Find a the strategy, using the name provided.
-
#initialize(provider, args) ⇒ Config
constructor
Create a new OmniAuth::Config.
Constructor Details
#initialize(provider, args) ⇒ Config
Create a new OmniAuth::Config
44 45 46 47 48 49 50 51 |
# File 'lib/negroni/omniauth/config.rb', line 44 def initialize(provider, args) @provider = provider @args = args @options = @args.last.is_a?(Hash) ? @args.last : {} @strategy = nil @strategy_name = [:name] || @provider @strategy_class = .delete(:strategy_class) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
24 25 26 |
# File 'lib/negroni/omniauth/config.rb', line 24 def args @args end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
28 29 30 |
# File 'lib/negroni/omniauth/config.rb', line 28 def @options end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
32 33 34 |
# File 'lib/negroni/omniauth/config.rb', line 32 def provider @provider end |
#strategy ⇒ Symbol
Returns the strategy for OmniAuth.
20 21 22 |
# File 'lib/negroni/omniauth/config.rb', line 20 def strategy @strategy end |
#strategy_class ⇒ Class (readonly)
Returns the class for the OmniAuth strategy.
|
# File 'lib/negroni/omniauth/config.rb', line 53
|
#strategy_name ⇒ Object (readonly)
Returns the value of attribute strategy_name.
37 38 39 |
# File 'lib/negroni/omniauth/config.rb', line 37 def strategy_name @strategy_name end |
Instance Method Details
#autoload_strategy ⇒ Object
Autoload a strategy
70 71 72 73 74 75 76 77 78 |
# File 'lib/negroni/omniauth/config.rb', line 70 def autoload_strategy name = ::OmniAuth::Utils.camelize(provider.to_s) if ::OmniAuth::Strategies.const_defined?(name) return ::OmniAuth::Strategies.const_get(name) end raise UnknownStrategy, name end |
#find_strategy ⇒ Object
Find a the strategy, using the name provided
62 63 64 65 66 67 |
# File 'lib/negroni/omniauth/config.rb', line 62 def find_strategy ::OmniAuth.strategies.find do |klass| klass.to_s =~ /#{::OmniAuth::Utils.camelize(strategy_name)}$/ || klass.[:name] == strategy_name end end |