Sha256: 8b7daa3136a974552bef2ee01d4c8a56796de3d203eb7fb7ecd5d4aecb6832c3
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
module Ninsho module OmniAuth class StrategyNotFound < NameError def initialize(strategy) @strategy = strategy super("Could not find a strategy with name `#{strategy}'." ) end end class Config attr_accessor :strategy attr_reader :args, :options, :provider, :strategy_name 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 def strategy_class @strategy_class ||= find_strategy || autoload_strategy end 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 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ninsho-0.0.1 | lib/ninsho/omniauth/config.rb |