Module: SwitchUser

Defined in:
lib/switch_user.rb,
lib/switch_user/rails.rb,
lib/switch_user/version.rb,
lib/switch_user/provider.rb,
lib/switch_user/user_set.rb,
lib/switch_user/base_guard.rb,
lib/switch_user/user_loader.rb,
lib/switch_user/lambda_guard.rb,
lib/switch_user/provider/base.rb,
lib/switch_user/provider/dummy.rb,
lib/switch_user/provider/devise.rb,
lib/switch_user/provider/session.rb,
lib/switch_user/provider/sorcery.rb,
lib/switch_user/provider/authlogic.rb,
lib/switch_user/provider/clearance.rb,
lib/switch_user/provider/restful_authentication.rb,
lib/generators/switch_user/install/install_generator.rb

Defined Under Namespace

Modules: Generators, Provider Classes: BaseGuard, Engine, InvalidScope, LambdaGuard, UserLoader, UserSet

Constant Summary collapse

VERSION =
"0.9.4"

Class Method Summary collapse

Class Method Details

.available_scopesObject



31
32
33
# File 'lib/switch_user.rb', line 31

def self.available_scopes
  available_users.keys
end

.guard_class=(klass) ⇒ Object



35
36
37
# File 'lib/switch_user.rb', line 35

def self.guard_class=(klass)
  @@guard_class = klass.constantize
end

.reset_configObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/switch_user.rb', line 39

def self.reset_config
  self.provider = :devise
  self.available_users = { :user => lambda { User.all } }
  self.available_users_identifiers = { :user => :id }
  self.available_users_names = { :user => :email }
  self.guard_class = "SwitchUser::LambdaGuard"
  self.controller_guard = lambda { |current_user, request| Rails.env.development? }
  self.view_guard = lambda { |current_user, request| Rails.env.development? }
  self.redirect_path = lambda { |request, params| request.env["HTTP_REFERER"] ? :back : root_path }
  self.session_key = :user_id
  self.helper_with_guest = true
  self.switch_back = false
  self. = true
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (SwitchUser)

    the object that the method was called on



27
28
29
# File 'lib/switch_user.rb', line 27

def self.setup
  yield self
end