Module: SimpleAuthentication::ControllerMethods::Application

Defined in:
lib/simple_authentication/controller_methods.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(controller) ⇒ Object



10
11
12
13
14
# File 'lib/simple_authentication/controller_methods.rb', line 10

def self.included(controller)
  [:logged_in?, :logged_out?, :current_user].each do |m|
    controller.helper_method m
  end
end

Instance Method Details

#current_userObject



17
18
19
# File 'lib/simple_authentication/controller_methods.rb', line 17

def current_user
  @_current_user ||= User.find_by_id(session[:current_user_id])
end

#logged_in?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/simple_authentication/controller_methods.rb', line 21

def logged_in?
  !!current_user
end

#logged_out?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/simple_authentication/controller_methods.rb', line 25

def logged_out?
  !logged_in?
end