Class: NavGate::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



21
22
23
24
25
26
# File 'lib/navgate.rb', line 21

def initialize
  self.controllers = Rails.application.routes.routes.map do |route|
    route.defaults[:controller]
  end.uniq.compact

end

Instance Attribute Details

#controllersObject

Returns the value of attribute controllers.



19
20
21
# File 'lib/navgate.rb', line 19

def controllers
  @controllers
end

#ignoringObject

Returns the value of attribute ignoring.



19
20
21
# File 'lib/navgate.rb', line 19

def ignoring
  @ignoring
end

Returns the value of attribute navs.



19
20
21
# File 'lib/navgate.rb', line 19

def navs
  @navs
end

Instance Method Details

#post_setupObject

Raises:

  • (TypeError)


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/navgate.rb', line 28

def post_setup
  raise TypeError, "Expected Navgate:Builder or string" unless not_bad_type?(self.navs)
  if self.navs.is_a?(String)
    setup = YAML.load_file(self.navs)
    temp = []
    setup.each do |menu|
      temp.push(Navgate::Builder.new do |options|
                  options[:selection] = menu[1]['selection'].split(" ")
                  options[:default] = menu[1]['default'] || nill
                  options[:prefix] = menu[1]['prefix'] || nil
                  options[:controller] = menu[1]['controller'] || nil
                  options[:by_id] = menu[1]['by_id'] || nil
                  options[:css_class] = menu[1]['css_class'] || nil
                end
              )
    end
    self.navs = temp
  end
  self.ignoring ||= [""]
end