Class: Navtastic::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/navtastic/configuration.rb

Overview

Configuration settings

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



35
36
37
38
39
40
# File 'lib/navtastic/configuration.rb', line 35

def initialize
  @renderer = Navtastic::Renderer::Simple
  @renderer_options = {}
  @reload_renderer = false
  @base_url = nil
end

Instance Attribute Details

#base_urlString?

The base url will be prepended to every item url

Defaults to nil.

Returns:

  • (String, nil)


10
11
12
# File 'lib/navtastic/configuration.rb', line 10

def base_url
  @base_url
end

#reload_rendererObject

Should the renderer class be reloaded everytime the menu is rendered?

This is helpful during development, to avoid restarting the server after every change, but should be disabled during production.

Defaults to false

Returns:

  • bool



33
34
35
# File 'lib/navtastic/configuration.rb', line 33

def reload_renderer
  @reload_renderer
end

#rendererObject

The default renderer to use when displaying a menu

Defaults to Renderer::Simple.

Returns:

  • any class that responds to the .render method



16
17
18
# File 'lib/navtastic/configuration.rb', line 16

def renderer
  @renderer
end

#renderer_optionsHash

Default options passed to the current renderer

Defaults to empty Hash.

Returns:

  • (Hash)


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

def renderer_options
  @renderer_options
end

Instance Method Details

#current_rendererNavtastic::Renderer

Will hot reload the renderer class if needed

Returns:



62
63
64
65
66
67
68
69
70
71
# File 'lib/navtastic/configuration.rb', line 62

def current_renderer
  klass = renderer

  if reload_renderer
    klass = klass.to_s unless klass.is_a?(String)
    Object.const_get(klass)
  else
    klass
  end
end