Module: NeonSakura::NavbarHelper

Defined in:
app/helpers/neon_sakura/navbar_helper.rb

Instance Method Summary collapse

Instance Method Details

#eval_nav_condition(condition) ⇒ Boolean

Safely evaluate a condition string in the current context

Parameters:

  • condition (String)

    The Ruby code to evaluate

Returns:

  • (Boolean)

    The result of the evaluation



25
26
27
28
29
30
31
32
# File 'app/helpers/neon_sakura/navbar_helper.rb', line 25

def eval_nav_condition(condition)
  return true if condition.nil? || condition.empty?

  instance_eval(condition.to_s)
rescue StandardError => e
  Rails.logger.warn("Failed to evaluate navbar condition '#{condition}': #{e.message}")
  false
end

Check if an icon exists before rendering

Parameters:

  • icon_name (String)

    The icon partial name

Returns:

  • (Boolean)

    true if the icon partial exists



37
38
39
40
41
# File 'app/helpers/neon_sakura/navbar_helper.rb', line 37

def nav_icon_exists?(icon_name)
  return false if icon_name.blank?

  lookup_context.exists?("shared/icons/#{icon_name}", [], true)
end

Check if a navigation link is currently active

Parameters:

  • link (Hash)

    The link configuration

Returns:

  • (Boolean)

    true if the link is active



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/neon_sakura/navbar_helper.rb', line 8

def nav_link_active?(link)
  return false unless link[:path]

  is_active = current_page?(link[:path]) rescue false
  return true if is_active

  # Check additional active_paths if present
  if link[:active_paths]
    link[:active_paths].any? { |path| current_page?(path) rescue false }
  else
    false
  end
end