Class: Ransack::Helpers::FormHelper::SortLink
- Inherits:
-
Object
- Object
- Ransack::Helpers::FormHelper::SortLink
- Defined in:
- lib/ransack/helpers/form_helper.rb
Instance Method Summary collapse
- #html_options(args) ⇒ Object
-
#initialize(search, attribute, args, params) ⇒ SortLink
constructor
A new instance of SortLink.
- #name ⇒ Object
- #url_options ⇒ Object
Constructor Details
#initialize(search, attribute, args, params) ⇒ SortLink
Returns a new instance of SortLink.
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/ransack/helpers/form_helper.rb', line 74 def initialize(search, attribute, args, params) @search = search @params = params @field = attribute.to_s sort_fields = extract_sort_fields_and_mutate_args!(args).compact @current_dir = existing_sort_direction @label_text = extract_label_and_mutate_args!(args) @options = (args) @hide_indicator = @options.delete :hide_indicator @default_order = @options.delete :default_order @sort_params = build_sort(sort_fields) @sort_params = @sort_params.first if @sort_params.size == 1 end |
Instance Method Details
#html_options(args) ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/ransack/helpers/form_helper.rb', line 101 def (args) = (args) .merge(class: [[Constants::SORT_LINK, @current_dir], [:class]] .compact.join(Constants::SPACE) ) end |
#name ⇒ Object
88 89 90 91 92 93 |
# File 'lib/ransack/helpers/form_helper.rb', line 88 def name [ERB::Util.h(@label_text), order_indicator] .compact .join(Constants::NON_BREAKING_SPACE) .html_safe end |
#url_options ⇒ Object
95 96 97 98 99 |
# File 'lib/ransack/helpers/form_helper.rb', line 95 def @params.merge( @options.merge( @search.context.search_key => search_and_sort_params)) end |