Module: NavigationHelper

Defined in:
app/helpers/navigation_helper.rb

Instance Method Summary collapse

Instance Method Details

#current_featureObject



13
14
15
16
17
18
# File 'app/helpers/navigation_helper.rb', line 13

def current_feature
  return nil unless current_project && current_project.persisted?
  @current_feature ||= current_project.features.find do |feature|
    current_page? feature_path(current_project, feature)
  end
end

#render_nav_for_feature(feature) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'app/helpers/navigation_helper.rb', line 20

def render_nav_for_feature(feature)
  feature = Houston.project_features[feature]
  return unless feature.permitted?(current_ability, current_project)

  render_nav_link feature.name, feature.path(current_project)
rescue KeyError
  Rails.logger.error "\e[31;1mThere is no project feature named #{feature.inspect}\e[0m"
  nil
end


30
31
32
33
34
35
36
# File 'app/helpers/navigation_helper.rb', line 30

def render_nav_link(name, href)
  if current_page? href
    "<li class=\"current\">#{h name}</li>".html_safe
  else
    "<li><a href=\"#{href}\" title=\"#{h name}\">#{h name}</a></li>".html_safe
  end
end

#render_navigation(key) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'app/helpers/navigation_helper.rb', line 3

def render_navigation(key)
  link = Houston.navigation[key]
  return unless link.permitted?(current_ability)

  render_nav_link link.name, link.path
rescue KeyError
  Rails.logger.error "\e[31;1mThere is no navigation renderer named #{key.inspect}\e[0m"
  nil
end