Module: C2::ControllerAdditions

Defined in:
lib/c2/controller_additions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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

def self.included(base)
  base.extend ClassMethods
  base.helper_method :current_c2_agent, :current_c2_agent_title, :c2_login_path, :c2_profile_path, :c2_logout_path
end

Instance Method Details

#authorize_c2_agentObject

Raises:



20
21
22
# File 'lib/c2/controller_additions.rb', line 20

def authorize_c2_agent
  raise C2::AccessDenied unless c2_clearance?
end

#c2_clearance?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/c2/controller_additions.rb', line 16

def c2_clearance?
  current_c2_agent && current_c2_agent.admin?
end

#c2_login_pathObject



24
25
26
# File 'lib/c2/controller_additions.rb', line 24

def 
  '/'
end

#c2_logout_pathObject



32
33
34
# File 'lib/c2/controller_additions.rb', line 32

def c2_logout_path
  '/'
end

#c2_profile_pathObject



28
29
30
# File 'lib/c2/controller_additions.rb', line 28

def c2_profile_path
  '/'
end

#current_c2_agentObject



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

def current_c2_agent
  @current_c2_agent ||= current_user
end

#current_c2_agent_titleObject



12
13
14
# File 'lib/c2/controller_additions.rb', line 12

def current_c2_agent_title
  @current_c2_agent_title ||= current_c2_agent.send(([:c2_title, :title, :name, :email].map(&:to_s) & current_c2_agent.methods).first)
end