Completed
Push — master ( 8ffdab...d9364e )
by
unknown
11s
created

ApplicationController.event_schedule_cache_key()   A

Complexity

Conditions 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
# Filters added to this controller apply to all controllers in the application.
2
# Likewise, all the methods added will be available for all controllers.
3
4
class ApplicationController < ActionController::Base
5
  helper :all # include all helpers, all the time
6
  helper :layout
7
  helper_method :current_participant
8
  helper_method :logged_in?
9
  protect_from_forgery # See ActionController::RequestForgeryProtection for details
10
11
  def current_participant
12
    @current_participant ||= (current_participant_session && current_participant_session.participant)
13
  end
14
  alias_method :current_user, :current_participant
15
16
  def current_participant_session
17
    return @current_participant_session if defined?(@current_participant_session)
18
    @current_participant_session = ParticipantSession.find
19
  end
20
21
  def logged_in?
22
    current_participant_session.present?
23
  end
24
25
  def verify_session
26
    unless logged_in?
27
      flash[:notice] = 'You must be logged in to do that. Please log in or create a new account and try again.'
28
      redirect_to new_login_path
29
    end
30
  end
31
32
  def event_schedule_cache_key(event)
33
    [
34
      event,
35
      event.sessions,
36
      event.participants,
37
      event.timeslots,
38
      event.rooms
39
    ]
40
  end
41
  helper_method :event_schedule_cache_key
42
end
43