Sha256: cb7bb1f0aa0a830ce668fa643ad96cff6f861ad02f81163162d4ed667cc25e1d
Contents?: true
Size: 1.18 KB
Versions: 35
Compression:
Stored size: 1.18 KB
Contents
# encoding: utf-8 module Warden module Strategies class << self # Add a strategy and store it in a hash. 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 # Update a previously given strategy. def update(label, &block) strategy = _strategies[label] raise "Unknown strategy #{label.inspect}" unless strategy add(label, strategy, &block) end # Provides access to strategies by label # :api: public def [](label) _strategies[label] end # Clears all declared. # :api: public def clear! _strategies.clear end # :api: private def _strategies @strategies ||= {} end end # << self end # Strategies end # Warden
Version data entries
35 entries across 34 versions & 3 rubygems