Class: ActiveElement::Routes
- Inherits:
-
Object
- Object
- ActiveElement::Routes
- 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
- #alternative_routes ⇒ Object
- #available ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(rails_component:, permissions: []) ⇒ Routes
constructor
A new instance of Routes.
- #permitted ⇒ Object
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 = @rails_component = rails_component end |
Instance Method Details
#alternative_routes ⇒ Object
22 23 24 |
# File 'lib/active_element/routes.rb', line 22 def alternative_routes @alternative_routes ||= available.select(&:primary?).reject { |route| route.path == '/' } end |
#available ⇒ Object
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 |
#permitted ⇒ Object
14 15 16 |
# File 'lib/active_element/routes.rb', line 14 def permitted @permitted ||= available_routes.select(&:permitted?) end |