Class: Coroutine::TinyNavigation::Data::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/tiny_navigation/data/config.rb

Overview

This class represents a configuration object. It is responsible for reading in the DSL and converting it to a structured set of navigation objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_controller, conf = File.join(Rails.root, "config", "tiny_navigation.rb")) ⇒ Config

This method creates a new configuration object. It reads in the configuration file and saves the contents to a class variable so it only has to be loaded once.

current_controller is a reference to the controller object being extended.

config is the location of the config file to load. Defaults to the generated file.



21
22
23
24
25
26
27
28
# File 'lib/tiny_navigation/data/config.rb', line 21

def initialize(current_controller, conf=File.join(Rails.root, "config", "tiny_navigation.rb"))
  @current_controller = current_controller
  @nav = {}

  Config.class_eval { class << self; attr_reader :file end; @file ||= File.read(conf) }
  
  self.instance_eval(Config.file);
end

Instance Attribute Details

:nodoc:



10
11
12
# File 'lib/tiny_navigation/data/config.rb', line 10

def nav
  @nav
end