Class: Devise::OmniAuth::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/devise/omniauth/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider, args) ⇒ Config

Returns a new instance of Config.



17
18
19
20
21
22
23
24
# File 'lib/devise/omniauth/config.rb', line 17

def initialize(provider, args)
  @provider       = provider
  @args           = args
  @options        = @args.last.is_a?(Hash) ? @args.last : {}
  @strategy       = nil
  @strategy_name  = options[:name] || @provider
  @strategy_class = options.delete(:strategy_class)
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



15
16
17
# File 'lib/devise/omniauth/config.rb', line 15

def args
  @args
end

#optionsObject (readonly)

Returns the value of attribute options.



15
16
17
# File 'lib/devise/omniauth/config.rb', line 15

def options
  @options
end

#providerObject (readonly)

Returns the value of attribute provider.



15
16
17
# File 'lib/devise/omniauth/config.rb', line 15

def provider
  @provider
end

#strategyObject

Returns the value of attribute strategy.



14
15
16
# File 'lib/devise/omniauth/config.rb', line 14

def strategy
  @strategy
end

#strategy_nameObject (readonly)

Returns the value of attribute strategy_name.



15
16
17
# File 'lib/devise/omniauth/config.rb', line 15

def strategy_name
  @strategy_name
end

Instance Method Details

#autoload_strategyObject



37
38
39
40
41
42
43
44
# File 'lib/devise/omniauth/config.rb', line 37

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_strategyObject



30
31
32
33
34
35
# File 'lib/devise/omniauth/config.rb', line 30

def find_strategy
  ::OmniAuth.strategies.find do |strategy_class|
    strategy_class.to_s =~ /#{::OmniAuth::Utils.camelize(strategy_name)}$/ ||
      strategy_class.default_options[:name] == strategy_name
  end
end

#strategy_classObject



26
27
28
# File 'lib/devise/omniauth/config.rb', line 26

def strategy_class
  @strategy_class ||= find_strategy || autoload_strategy
end