Class: SwitchUser::BaseGuard

Inherits:
Object
  • Object
show all
Defined in:
lib/switch_user/base_guard.rb

Direct Known Subclasses

LambdaGuard

Instance Method Summary collapse

Constructor Details

#initialize(controller, provider) ⇒ BaseGuard

TODO is this the best arguments for the initializer ? TODO should @provider be set and current/original_user be added as # accessors ?



5
6
7
8
9
10
# File 'lib/switch_user/base_guard.rb', line 5

def initialize(controller, provider)
  @controller    = controller
  @request       = controller.request
  @current_user  = provider.current_user
  @original_user = provider.original_user
end

Instance Method Details

#controller_available?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/switch_user/base_guard.rb', line 12

def controller_available?
  raise NotImplementedError.new("you must implement controller_available?")
end

#view_available?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/switch_user/base_guard.rb', line 16

def view_available?
  controller_available?
end