class AuthStrategist::BuildStrategy
Attributes
strategy[R]
Public Class Methods
call(params = {})
click to toggle source
# File lib/auth_strategist/build_strategy.rb, line 5 def self.call(params = {}) new.call(params) end
Public Instance Methods
call(params = {})
click to toggle source
# File lib/auth_strategist/build_strategy.rb, line 9 def call(params = {}) choose_strategy(params) end
Private Instance Methods
choose_strategy(params = {})
click to toggle source
# File lib/auth_strategist/build_strategy.rb, line 17 def choose_strategy(params = {}) strategy_key = params[:strategy] raise(strategy_key_nil) if strategy_key.nil? strategy_class = begin strategies.resolve(strategy_key) rescue StandardError nil end raise(strategy_not_found(strategy_key)) if strategy_class.nil? strategy_params = params.dup.tap { |h| h.delete(:strategy) } strategy_class.new(strategy_params) end
strategies()
click to toggle source
# File lib/auth_strategist/build_strategy.rb, line 33 def strategies AuthStrategist.strategies end
strategy_key_nil()
click to toggle source
# File lib/auth_strategist/build_strategy.rb, line 41 def strategy_key_nil StandardError.new(':strategy option must not be nil.') end
strategy_not_found(strategy_key)
click to toggle source
# File lib/auth_strategist/build_strategy.rb, line 37 def strategy_not_found(strategy_key) StandardError.new("Strategy '#{strategy_key}' was not found.") end