Module: C2::ControllerAdditions
- Defined in:
- lib/c2/controller_additions.rb
Class Method Summary collapse
Instance Method Summary collapse
- #authorize_c2_agent ⇒ Object
- #c2_clearance? ⇒ Boolean
- #c2_login_path ⇒ Object
- #c2_logout_path ⇒ Object
- #c2_profile_path ⇒ Object
- #current_c2_agent ⇒ Object
- #current_c2_agent_title ⇒ Object
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_agent ⇒ Object
20 21 22 |
# File 'lib/c2/controller_additions.rb', line 20 def raise C2::AccessDenied unless c2_clearance? end |
#c2_clearance? ⇒ 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_path ⇒ Object
24 25 26 |
# File 'lib/c2/controller_additions.rb', line 24 def c2_login_path '/' end |
#c2_logout_path ⇒ Object
32 33 34 |
# File 'lib/c2/controller_additions.rb', line 32 def c2_logout_path '/' end |
#c2_profile_path ⇒ Object
28 29 30 |
# File 'lib/c2/controller_additions.rb', line 28 def c2_profile_path '/' end |
#current_c2_agent ⇒ Object
8 9 10 |
# File 'lib/c2/controller_additions.rb', line 8 def current_c2_agent @current_c2_agent ||= current_user end |
#current_c2_agent_title ⇒ Object
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 |