Class: Bard::Static::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 Bard::Static::LinkToHelper::LinkTo

Instance Attribute Details

#current_pathObject

Returns the value of attribute current_path.



72
73
74
# File 'app/helpers/bard/static/link_to_helper.rb', line 72

def current_path
  @current_path
end

Instance Method Details

#add_class(class_name) ⇒ Object



74
75
76
77
78
# File 'app/helpers/bard/static/link_to_helper.rb', line 74

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

#current_conditionObject



85
86
87
# File 'app/helpers/bard/static/link_to_helper.rb', line 85

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

#renderObject



80
81
82
83
# File 'app/helpers/bard/static/link_to_helper.rb', line 80

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