Class: ActiveElement::ActiveMenuLink

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

Overview

Detects which link should be highlighted in the main application menu.

Instance Method Summary collapse

Constructor Details

#initialize(rails_component:, current_path:, controller_path:, action_name:, current_navbar_item:, navbar_items:) ⇒ ActiveMenuLink

rubocop:disable Metrics/ParameterLists



7
8
9
10
11
12
13
14
# File 'lib/active_element/active_menu_link.rb', line 7

def initialize(rails_component:, current_path:, controller_path:, action_name:, current_navbar_item:, navbar_items:)
  @rails_component = rails_component
  @current_path = current_path
  @controller_path = controller_path
  @action_name = action_name
  @current_navbar_item = current_navbar_item
  @navbar_items = navbar_items
end

Instance Method Details

#active?Boolean

rubocop:enable Metrics/ParameterLists

Returns:

  • (Boolean)


17
18
19
20
21
22
23
# File 'lib/active_element/active_menu_link.rb', line 17

def active?
  return true if exact_match?
  return true if !any_exact_match? && exact_without_query_string_match?
  return true if !any_exact_match? && !any_exact_without_query_string_match? && exact_without_resource_match?

  false
end