Class: HorizontalNav

Inherits:
Object
  • Object
show all
Defined in:
app/models/horizontal_nav.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#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

.for_user(user, args = {}) ⇒ Object



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

#current_navableObject



25
26
27
# File 'app/models/horizontal_nav.rb', line 25

def current_navable
  @current_navable
end

#currently_in_intranet?Boolean

Returns:

  • (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


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

#logged_in?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/models/horizontal_nav.rb', line 29

def logged_in?
  return true if @user
end


17
18
19
# File 'app/models/horizontal_nav.rb', line 17

def navables
  [ Page.find_intranet_root ] + (@user.try(:current_corporations) || [])
end