Class: Ransack::Helpers::FormHelper::SortLink
- Inherits:
-
Object
- Object
- Ransack::Helpers::FormHelper::SortLink
- Defined in:
- lib/ransack/helpers/form_helper.rb
Instance Method Summary collapse
- #default_arrow ⇒ Object
- #down_arrow ⇒ Object
- #html_options(args) ⇒ Object
-
#initialize(search, attribute, args, params) ⇒ SortLink
constructor
A new instance of SortLink.
- #name ⇒ Object
- #up_arrow ⇒ Object
- #url_options ⇒ Object
Constructor Details
#initialize(search, attribute, args, params) ⇒ SortLink
Returns a new instance of SortLink.
165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/ransack/helpers/form_helper.rb', line 165 def initialize(search, attribute, args, params) @search = search @params = parameters_hash(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) = (args) @hide_indicator = .delete(:hide_indicator) || Ransack.[:hide_sort_order_indicators] @default_order = .delete :default_order end |
Instance Method Details
#default_arrow ⇒ Object
186 187 188 |
# File 'lib/ransack/helpers/form_helper.rb', line 186 def default_arrow Ransack.[:default_arrow] end |
#down_arrow ⇒ Object
182 183 184 |
# File 'lib/ransack/helpers/form_helper.rb', line 182 def down_arrow Ransack.[:down_arrow] end |
#html_options(args) ⇒ Object
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/ransack/helpers/form_helper.rb', line 203 def (args) if args.empty? = else = "Passing two trailing hashes to `sort_link` is deprecated, merge the trailing hashes into a single one." caller_location = caller_locations(2, 2).first warn "#{deprecation_message} (called at #{caller_location.path}:#{caller_location.lineno})" = (args) end .merge( class: [['sort_link'.freeze, @current_dir], [:class]] .compact.join(' '.freeze) ) end |
#name ⇒ Object
190 191 192 193 194 195 |
# File 'lib/ransack/helpers/form_helper.rb', line 190 def name [ERB::Util.h(@label_text), order_indicator] .compact .join(' '.freeze) .html_safe end |
#up_arrow ⇒ Object
178 179 180 |
# File 'lib/ransack/helpers/form_helper.rb', line 178 def up_arrow Ransack.[:up_arrow] end |
#url_options ⇒ Object
197 198 199 200 201 |
# File 'lib/ransack/helpers/form_helper.rb', line 197 def @params.except(:host).merge( .except(:class, :data, :host).merge( @search.context.search_key => search_and_sort_params)) end |