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



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

def config 
  Configuration.instance
end

.config_file_name(navigation_context = :default) ⇒ Object

Returns the path to the config_file for the given navigation_context



42
43
44
45
# File 'lib/simple_navigation.rb', line 42

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.



21
22
23
24
25
26
27
28
29
# File 'lib/simple_navigation.rb', line 21

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



37
38
39
# File 'lib/simple_navigation.rb', line 37

def primary_navigation
  config.primary_navigation
end