class Negroni::OmniAuth::Config
Attributes
args[R]
@!attribute [r] args
@return [Array<Object>] arguments needed to configure the provider
options[R]
@!attribute [r] options
@return [Hash] options needed to configure the provider
provider[R]
@!attribute [r] provider
@return [Symbol] the name of the OmniAuth provider
strategy[RW]
@!attribute [rw] strategy
@return [Symbol] the strategy for OmniAuth
strategy_name[R]
@!attribute [r] strategy_name
@return [String, Symbol] the name of the strategy, if different from `provider`
Public Class Methods
new(provider, args)
click to toggle source
Create a new OmniAuth::Config
@param provider [Symbol] the name of the provider to use @param args [Array<Object>] any arguments to pass to the provider
# 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 = options[:name] || @provider @strategy_class = options.delete(:strategy_class) end
Public Instance Methods
autoload_strategy()
click to toggle source
Autoload a strategy
# 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()
click to toggle source
Find a the strategy, using the name provided
# 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.default_options[:name] == strategy_name end end
strategy_class()
click to toggle source
@return [Class] the class for the OmniAuth
strategy
# File lib/negroni/omniauth/config.rb, line 57 def strategy_class @strategy_class ||= find_strategy || autoload_strategy end