Module: DeviseCasAuthenticatable::SingleSignOut::Strategies

Defined in:
lib/devise_cas_authenticatable/single_sign_out/strategies.rb,
lib/devise_cas_authenticatable/single_sign_out/strategies/base.rb,
lib/devise_cas_authenticatable/single_sign_out/strategies/rails_cache.rb

Defined Under Namespace

Classes: Base, RailsCache

Class Method Summary collapse

Class Method Details

.[](label) ⇒ Object

Provides access to strategies by label



30
31
32
# File 'lib/devise_cas_authenticatable/single_sign_out/strategies.rb', line 30

def [](label)
  _strategies[label]
end

.add(label, strategy, &block) ⇒ Object

Add a strategy and store it in a hash.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/devise_cas_authenticatable/single_sign_out/strategies.rb', line 7

def add(label, strategy, &block)
  strategy ||= Class.new(DeviseCasAuthenticatable::SingleSignOut::Strategies::Base)
  strategy.class_eval(&block) if block_given?

  check_method(label, strategy, :store_session_id_for_index)
  check_method(label, strategy, :find_session_id_by_index)
  check_method(label, strategy, :delete_session_index)

  unless strategy.ancestors.include?(DeviseCasAuthenticatable::SingleSignOut::Strategies::Base)
    raise "#{label.inspect} is not a #{base}"
  end

  _strategies[label] = strategy.new()
end

.clear!Object

Clears all declared.



39
40
41
# File 'lib/devise_cas_authenticatable/single_sign_out/strategies.rb', line 39

def clear!
  _strategies.clear
end

.current_strategyObject



34
35
36
# File 'lib/devise_cas_authenticatable/single_sign_out/strategies.rb', line 34

def current_strategy
  self[::Devise.cas_single_sign_out_mapping_strategy]
end

.update(label, &block) ⇒ Object

Update a previously given strategy.



23
24
25
26
27
# File 'lib/devise_cas_authenticatable/single_sign_out/strategies.rb', line 23

def update(label, &block)
  strategy = _strategies[label]
  raise "Unknown strategy #{label.inspect}" unless strategy
  add(label, strategy, &block)
end