Class: BardStatic::LinkToHelper::LinkToCurrent

Inherits:
LinkTo
  • Object
show all
Defined in:
app/helpers/bard_static/link_to_helper.rb

Direct Known Subclasses

LinkToNav

Instance Attribute Summary collapse

Attributes inherited from LinkTo

#context, #html_options, #name, #options

Instance Method Summary collapse

Methods inherited from LinkTo

#initialize, render, #url

Constructor Details

This class inherits a constructor from BardStatic::LinkToHelper::LinkTo

Instance Attribute Details

#current_pathObject

Returns the value of attribute current_path.



66
67
68
# File 'app/helpers/bard_static/link_to_helper.rb', line 66

def current_path
  @current_path
end

Instance Method Details

#add_class(class_name) ⇒ Object



68
69
70
71
72
# File 'app/helpers/bard_static/link_to_helper.rb', line 68

def add_class class_name
  html_options[:class] ||= ""
  html_options[:class] << " #{class_name}"
  html_options[:class].strip!
end

#current_conditionObject



79
80
81
# File 'app/helpers/bard_static/link_to_helper.rb', line 79

def current_condition
  html_options.delete(:if) || current_path == url
end

#renderObject



74
75
76
77
# File 'app/helpers/bard_static/link_to_helper.rb', line 74

def render
  add_class("current") if current_condition
  super
end