class Warden::Config
This class is yielded inside Warden::Manager
. If you have a plugin and want to add more configuration to warden, you just need to extend this class.
Public Class Methods
new(other={})
click to toggle source
# File lib/warden/config.rb, line 37 def initialize(other={}) merge!(other) self[:default_scope] ||= :default self[:scope_defaults] ||= {} self[:default_strategies] ||= {} self[:intercept_401] = true unless key?(:intercept_401) end
Public Instance Methods
default_strategies(*strategies)
click to toggle source
Set the default strategies to use. :api: public
# File lib/warden/config.rb, line 63 def default_strategies(*strategies) opts = Hash === strategies.last ? strategies.pop : {} hash = self[:default_strategies] scope = opts[:scope] || :_all hash[scope] = strategies.flatten unless strategies.empty? hash[scope] || hash[:_all] || [] end
initialize_copy(other)
click to toggle source
Calls superclass method
# File lib/warden/config.rb, line 45 def initialize_copy(other) super deep_dup(:scope_defaults, other) deep_dup(:default_strategies, other) end
scope_defaults(scope, opts = {})
click to toggle source
A short hand way to set up a particular scope :api: public
# File lib/warden/config.rb, line 74 def scope_defaults(scope, opts = {}) if strategies = opts.delete(:strategies) default_strategies(strategies, :scope => scope) end if opts.empty? self[:scope_defaults][scope] || {} else self[:scope_defaults][scope] ||= {} self[:scope_defaults][scope].merge!(opts) end end
serialize_from_session(*args, &block)
click to toggle source
Hook from configuration to serialize_from_session. :api: public
# File lib/warden/config.rb, line 101 def serialize_from_session(*args, &block) Warden::Manager.serialize_from_session(*args, &block) end
serialize_into_session(*args, &block)
click to toggle source
Hook from configuration to serialize_into_session. :api: public
# File lib/warden/config.rb, line 95 def serialize_into_session(*args, &block) Warden::Manager.serialize_into_session(*args, &block) end
silence_missing_strategies!()
click to toggle source
Do not raise an error if a missing strategy is given. :api: plugin
# File lib/warden/config.rb, line 53 def silence_missing_strategies! self[:silence_missing_strategies] = true end
strategies()
click to toggle source
Quick accessor to strategies from manager :api: public
# File lib/warden/config.rb, line 89 def strategies Warden::Strategies end
Protected Instance Methods
deep_dup(key, other)
click to toggle source
# File lib/warden/config.rb, line 107 def deep_dup(key, other) self[key] = hash = other[key].dup hash.each { |k, v| hash[k] = v.dup } end