Class: Super::Navigation

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

Defined Under Namespace

Classes: Builder, Menu, RouteFormatterButReallySearcher

Instance Method Summary collapse

Constructor Details

#initialize {|@builder| ... } ⇒ Navigation

Returns a new instance of Navigation.

Yields:

  • (@builder)


5
6
7
8
# File 'lib/super/navigation.rb', line 5

def initialize
  @builder = Builder.new
  yield @builder
end

Instance Method Details

#definitionObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/super/navigation.rb', line 10

def definition
  return @definition if instance_variable_defined?(:@definition)

  searcher = RouteFormatterButReallySearcher.new
  inspector = ActionDispatch::Routing::RoutesInspector.new(Rails.application.routes.routes)
  inspector.format(searcher)
  all_matches = searcher.matches
  unused_matches = all_matches.each_with_object({}) { |match, hash| hash[match] = true }

  defs = validate_and_determine_explicit_links(@builder.build, unused_matches)
  @definition = expand_directives(defs, all_matches, unused_matches.keys)
end