Module: Warden::Strategies
- Defined in:
- lib/warden/strategies.rb,
lib/warden/strategies/base.rb
Defined Under Namespace
Classes: Base
Class Method Summary (collapse)
-
+ (Object) [](label)
Provides access to strategies by label :api: public.
-
+ (Object) _strategies
:api: private.
-
+ (Object) add(label, strategy = nil, &block)
Add a strategy and store it in a hash.
-
+ (Object) clear!
Clears all declared.
-
+ (Object) update(label, &block)
Update a previously given strategy.
Class Method Details
+ (Object) [](label)
Provides access to strategies by label :api: public
30 31 32 |
# File 'lib/warden/strategies.rb', line 30 def [](label) _strategies[label] end |
+ (Object) _strategies
:api: private
41 42 43 |
# File 'lib/warden/strategies.rb', line 41 def _strategies @strategies ||= {} end |
+ (Object) add(label, strategy = nil, &block)
Add a strategy and store it in a hash.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/warden/strategies.rb', line 6 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 unless strategy.ancestors.include?(Warden::Strategies::Base) raise "#{label.inspect} is not a #{base}" end _strategies[label] = strategy end |
+ (Object) clear!
Clears all declared. :api: public
36 37 38 |
# File 'lib/warden/strategies.rb', line 36 def clear! _strategies.clear end |
+ (Object) update(label, &block)
Update a previously given strategy.
22 23 24 25 26 |
# 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 |