Module: SimpleNavigation

Defined in:
lib/simple_navigation.rb,
lib/simple_navigation/item.rb,
lib/simple_navigation/helpers.rb,
lib/simple_navigation/configuration.rb,
lib/simple_navigation/renderer/base.rb,
lib/simple_navigation/renderer/list.rb,
lib/simple_navigation/item_container.rb,
lib/simple_navigation/controller_methods.rb

Overview

TODO: add :except and :only options to navigation method

Defined Under Namespace

Modules: ControllerMethods, Helpers, Renderer Classes: Configuration, Item, ItemContainer

Class Method Summary collapse

Class Method Details

.configObject

Returns the singleton instance of the SimpleNavigation::Configuration



23
24
25
# File 'lib/simple_navigation.rb', line 23

def config 
  Configuration.instance
end

.config_file_name(navigation_context = :default) ⇒ Object

Returns the path to the config_file for the given navigation_context



33
34
35
36
# File 'lib/simple_navigation.rb', line 33

def config_file_name(navigation_context = :default)
  file_name = navigation_context == :default ? '' : "#{navigation_context.to_s.underscore}_"
  File.join(config_file_path, "#{file_name}navigation.rb")
end

.load_config(navigation_context = :default) ⇒ Object

Reads the config_file for the specified navigation_context and stores it for later evaluation.



12
13
14
15
16
17
18
19
20
# File 'lib/simple_navigation.rb', line 12

def load_config(navigation_context = :default)
  raise "config_file_path is not set!" unless self.config_file_path
  raise "Config file '#{config_file_name(navigation_context)}' does not exists!" unless File.exists?(config_file_name(navigation_context))
  if ::RAILS_ENV == 'production'
    self.config_files[navigation_context] ||= IO.read(config_file_name(navigation_context))
  else
    self.config_files[navigation_context] = IO.read(config_file_name(navigation_context))
  end
end

.primary_navigationObject

Returns the ItemContainer that contains the items for the primary navigation



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

def primary_navigation
  config.primary_navigation
end