Method: Navgate#initialize

Defined in:
lib/navgate.rb

#initialize {|_self| ... } ⇒ Navgate

Returns a new instance of Navgate.

Yields:

  • (_self)

Yield Parameters:

  • _self (Navgate)

    the object that the method was called on

Raises:

  • (TypeError)


102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/navgate.rb', line 102

def initialize
  self.controllers = Rails.application.routes.routes.map do |route|
    route.defaults[:controller]
  end.uniq.compact
  yield(self)
  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