module Warden::Strategies
Public Instance Methods
[](label)
click to toggle source
Provides access to strategies by label :api: public
# File lib/warden/strategies.rb, line 30 def [](label) _strategies[label] end
_strategies()
click to toggle source
:api: private
# File lib/warden/strategies.rb, line 41 def _strategies @strategies ||= {} end
add(label, strategy = nil, &block)
click to toggle source
Add a strategy and store it in a hash.
# File lib/warden/strategies.rb, line 5 def add(label, strategy = nil, &block) strategy ||= Class.new(Warden::Strategies::Base) strategy.class_eval(&block) if block_given? unless strategy.method_defined?(:authenticate!) raise NoMethodError, "authenticate! is not declared in the #{label.inspect} strategy" end base = Warden::Strategies::Base unless strategy.ancestors.include?(base) raise "#{label.inspect} is not a #{base}" end _strategies[label] = strategy end
clear!()
click to toggle source
Clears all declared. :api: public
# File lib/warden/strategies.rb, line 36 def clear! _strategies.clear end
update(label, &block)
click to toggle source
Update a previously given strategy.
# File lib/warden/strategies.rb, line 22 def update(label, &block) strategy = _strategies[label] raise "Unknown strategy #{label.inspect}" unless strategy add(label, strategy, &block) end