Class: Ninsho::OmniAuth::Config
- Inherits:
-
Object
- Object
- Ninsho::OmniAuth::Config
- Defined in:
- lib/ninsho/omniauth/config.rb
Overview
Responsible for setting upt the configuration for omniauth providers and mount it into ninsho
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 ⇒ Object
Returns the value of attribute strategy.
-
#strategy_name ⇒ Object
readonly
Returns the value of attribute strategy_name.
Instance Method Summary collapse
- #autoload_strategy ⇒ Object
- #find_strategy ⇒ Object
-
#initialize(provider, args) ⇒ Config
constructor
A new instance of Config.
- #strategy_class ⇒ Object
Constructor Details
#initialize(provider, args) ⇒ Config
Returns a new instance of Config.
16 17 18 19 20 21 22 23 |
# File 'lib/ninsho/omniauth/config.rb', line 16 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.
14 15 16 |
# File 'lib/ninsho/omniauth/config.rb', line 14 def args @args end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/ninsho/omniauth/config.rb', line 14 def @options end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
14 15 16 |
# File 'lib/ninsho/omniauth/config.rb', line 14 def provider @provider end |
#strategy ⇒ Object
Returns the value of attribute strategy.
13 14 15 |
# File 'lib/ninsho/omniauth/config.rb', line 13 def strategy @strategy end |
#strategy_name ⇒ Object (readonly)
Returns the value of attribute strategy_name.
14 15 16 |
# File 'lib/ninsho/omniauth/config.rb', line 14 def strategy_name @strategy_name end |
Instance Method Details
#autoload_strategy ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/ninsho/omniauth/config.rb', line 36 def autoload_strategy name = ::OmniAuth::Utils.camelize(provider.to_s) if ::OmniAuth::Strategies.const_defined?(name) ::OmniAuth::Strategies.const_get(name) else raise StrategyNotFound, name end end |
#find_strategy ⇒ Object
29 30 31 32 33 34 |
# File 'lib/ninsho/omniauth/config.rb', line 29 def find_strategy ::OmniAuth.strategies.find do |strategy_class| strategy_class.to_s =~ /#{::OmniAuth::Utils.camelize(strategy_name)}$/ || strategy_class.[:name] == strategy_name end end |
#strategy_class ⇒ Object
25 26 27 |
# File 'lib/ninsho/omniauth/config.rb', line 25 def strategy_class @strategy_class ||= find_strategy || autoload_strategy end |