Module: AerpeAuth::Controller

Defined in:
lib/aerpe_auth.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(controller) ⇒ Object



3
4
5
6
# File 'lib/aerpe_auth.rb', line 3

def self.included(controller)
  controller.send :helper_method, :current_user_session, :current_user, :logged_in
  controller.send :before_filter, AuthorizationSubject
end

Instance Method Details

#current_userObject



17
18
19
20
# File 'lib/aerpe_auth.rb', line 17

def current_user
  return @current_user if defined?(@current_user)
  @current_user = current_user_session && current_user_session.record
end

#current_user_sessionObject



12
13
14
15
# File 'lib/aerpe_auth.rb', line 12

def current_user_session
  return @current_user_session if defined?(@current_user_session)
  @current_user_session = UserSession.find
end

#logged_inObject



8
9
10
# File 'lib/aerpe_auth.rb', line 8

def logged_in
  !!current_user
end