Class: ActiveElement::Routes

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/active_element/routes.rb

Overview

Provides an interface to available admin routes, used for populating a default navigation bar and detecting available permitted routes if the default root path is not permitted.

Instance Method Summary collapse

Constructor Details

#initialize(rails_component:, permissions: []) ⇒ Routes

Returns a new instance of Routes.



9
10
11
12
# File 'lib/active_element/routes.rb', line 9

def initialize(rails_component:, permissions: [])
  @permissions = permissions
  @rails_component = rails_component
end

Instance Method Details

#alternative_routesObject



22
23
24
# File 'lib/active_element/routes.rb', line 22

def alternative_routes
  @alternative_routes ||= available.select(&:primary?).reject { |route| route.path == '/' }
end

#availableObject



18
19
20
# File 'lib/active_element/routes.rb', line 18

def available
  @available ||= available_routes
end

#each(&block) ⇒ Object



26
27
28
# File 'lib/active_element/routes.rb', line 26

def each(&block)
  available.each(&block)
end

#permittedObject



14
15
16
# File 'lib/active_element/routes.rb', line 14

def permitted
  @permitted ||= available_routes.select(&:permitted?)
end