Skip to content

Commit

Permalink
. cosmetic
Browse files Browse the repository at this point in the history
  • Loading branch information
andi committed Jul 28, 2009
1 parent 96cbff3 commit 785baec
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions lib/simple_navigation.rb
Expand Up @@ -6,31 +6,35 @@ module SimpleNavigation
mattr_accessor :controller
self.config_files = {}

# Reads the config_file for the specified navigation_context and stores it for later evaluation.
def self.load_config(navigation_context = :default)
raise "config_file_path is not set!" unless self.config_file_path
raise "Config file '#{self.config_file_name}' does not exists!" unless File.exists?(self.config_file_name)
if ::RAILS_ENV == 'production'
self.config_files[navigation_context] ||= IO.read(self.config_file_name)
else
self.config_files[navigation_context] = IO.read(self.config_file_name)
class << self

# Reads the config_file for the specified navigation_context and stores it for later evaluation.
def load_config(navigation_context = :default)
raise "config_file_path is not set!" unless config_file_path
raise "Config file '#{config_file_name}' does not exists!" unless File.exists?(config_file_name)
if ::RAILS_ENV == 'production'
config_files[navigation_context] ||= IO.read(config_file_name)
else
config_files[navigation_context] = IO.read(config_file_name)
end
end
end

# Returns the singleton instance of the SimpleNavigation::Configuration
def self.config
Configuration.instance
end
# Returns the singleton instance of the SimpleNavigation::Configuration
def config
Configuration.instance
end

# Returns the ItemContainer that contains the items for the primary navigation
def self.primary_navigation
config.primary_navigation
end
# Returns the ItemContainer that contains the items for the primary navigation
def primary_navigation
config.primary_navigation
end

# Returns the path to the config_file for the given navigation_context
def self.config_file_name(navigation_context = :default)
file_name = navigation_context == :default ? '' : "#{navigation_context.to_s.underscore}_"
File.join(self.config_file_path, "#{file_name}navigation.rb")
# Returns the path to the config_file for the given navigation_context
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

end

end

0 comments on commit 785baec

Please sign in to comment.