Class: Rails::AddOns::TableHelper::SortLink
- Inherits:
-
Object
- Object
- Rails::AddOns::TableHelper::SortLink
- Defined in:
- app/helpers/rails/add_ons/table_helper.rb
Instance Method Summary collapse
-
#initialize(view_context, column_name, title, options) ⇒ SortLink
constructor
A new instance of SortLink.
- #perform ⇒ Object
Constructor Details
#initialize(view_context, column_name, title, options) ⇒ SortLink
Returns a new instance of SortLink.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/rails/add_ons/table_helper.rb', line 18 def initialize(view_context, column_name, title, ) = {} if === true = else = .reverse_merge() end @view_context = view_context @column_name = column_name @title = title if h.params[:sort_direction].present? @sort_direction = (h.params[:sort_direction].to_sym == :asc) ? :desc : :asc else @sort_direction = :asc end end |
Instance Method Details
#perform ⇒ Object
38 39 40 |
# File 'app/helpers/rails/add_ons/table_helper.rb', line 38 def perform h.link_to(@title, h.url_for(sort_by: @column_name, sort_direction: @sort_direction)) end |