Class: HorizontalNav
- Inherits:
-
Object
- Object
- HorizontalNav
- Defined in:
- app/models/horizontal_nav.rb
Class Method Summary collapse
Instance Method Summary collapse
- #current_navable ⇒ Object
- #currently_in_intranet? ⇒ Boolean
-
#initialize(args) ⇒ HorizontalNav
constructor
A new instance of HorizontalNav.
- #link_objects ⇒ Object
- #logged_in? ⇒ Boolean
- #navables ⇒ Object
Constructor Details
permalink #initialize(args) ⇒ HorizontalNav
Returns a new instance of HorizontalNav.
2 3 4 5 |
# File 'app/models/horizontal_nav.rb', line 2 def initialize(args) @user = args[:user] @current_navable = args[:current_navable] end |
Class Method Details
permalink .for_user(user, args = {}) ⇒ Object
[View source]
7 8 9 |
# File 'app/models/horizontal_nav.rb', line 7 def self.for_user(user, args = {}) self.new(args.merge({ user: user })) end |
Instance Method Details
permalink #current_navable ⇒ Object
[View source]
25 26 27 |
# File 'app/models/horizontal_nav.rb', line 25 def current_navable @current_navable end |
permalink #currently_in_intranet? ⇒ Boolean
21 22 23 |
# File 'app/models/horizontal_nav.rb', line 21 def currently_in_intranet? current_navable.ancestor_pages.include? Page.find_intranet_root end |
permalink #link_objects ⇒ Object
[View source]
11 12 13 14 15 |
# File 'app/models/horizontal_nav.rb', line 11 def link_objects objects = navables objects << { title: I18n.t(:sign_in), :controller => '/sessions', :action => :new } if not logged_in? objects end |
permalink #logged_in? ⇒ Boolean
29 30 31 |
# File 'app/models/horizontal_nav.rb', line 29 def logged_in? return true if @user end |
permalink #navables ⇒ Object
[View source]
17 18 19 |
# File 'app/models/horizontal_nav.rb', line 17 def navables [ Page.find_intranet_root ] + (@user.try(:current_corporations) || []) end |