Module: Interage::ControllerActiveHelper

Included in:
ApplicationHelper
Defined in:
lib/interage/controller_active_helper.rb

Constant Summary collapse

HTML_SHOW_CLASS =
ENV.fetch('CONTROLLER_SHOW_CLASS', 'show')
HTML_ACTIVE_CLASS =
ENV.fetch('CONTROLLER_ACTIVE_CLASS', 'active')

Instance Method Summary collapse

Instance Method Details

#action_class_active(*actions) ⇒ Object



28
29
30
# File 'lib/interage/controller_active_helper.rb', line 28

def action_class_active(*actions)
  HTML_ACTIVE_CLASS if current_action?(*actions)
end

#controller_class_active(*controllers) ⇒ Object Also known as: menu_active



14
15
16
# File 'lib/interage/controller_active_helper.rb', line 14

def controller_class_active(*controllers)
  HTML_ACTIVE_CLASS if current_controller?(*controllers)
end

#controller_class_active_show(*controllers) ⇒ Object



8
9
10
11
12
# File 'lib/interage/controller_active_helper.rb', line 8

def controller_class_active_show(*controllers)
  return unless current_controller?(*controllers)

  "#{HTML_SHOW_CLASS} #{HTML_ACTIVE_CLASS}"
end

#controller_class_show(*controllers) ⇒ Object Also known as: menu_class_show



19
20
21
# File 'lib/interage/controller_active_helper.rb', line 19

def controller_class_show(*controllers)
  HTML_SHOW_CLASS if current_controller?(*controllers)
end

#current_action?(*actions) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/interage/controller_active_helper.rb', line 32

def current_action?(*actions)
  Array.wrap(actions).include?("#{controller_name}/#{action_name}")
end

#current_controller?(*controllers) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/interage/controller_active_helper.rb', line 24

def current_controller?(*controllers)
  Array.wrap(controllers).include?(params[:controller])
end