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.
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/ransack/helpers/form_helper.rb', line 99 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) @options = (args) @hide_indicator = @options.delete(:hide_indicator) || Ransack.[:hide_sort_order_indicators] @default_order = @options.delete :default_order end |
Instance Method Details
#default_arrow ⇒ Object
120 121 122 |
# File 'lib/ransack/helpers/form_helper.rb', line 120 def default_arrow Ransack.[:default_arrow] end |
#down_arrow ⇒ Object
116 117 118 |
# File 'lib/ransack/helpers/form_helper.rb', line 116 def down_arrow Ransack.[:down_arrow] end |
#html_options(args) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/ransack/helpers/form_helper.rb', line 137 def (args) if args.empty? = @options 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 "#{} (called at #{caller_location.path}:#{caller_location.lineno})" = (args) end .merge( class: [['sort_link'.freeze, @current_dir], [:class]] .compact.join(' '.freeze) ) end |
#name ⇒ Object
124 125 126 127 128 129 |
# File 'lib/ransack/helpers/form_helper.rb', line 124 def name [ERB::Util.h(@label_text), order_indicator] .compact .join(' '.freeze) .html_safe end |
#up_arrow ⇒ Object
112 113 114 |
# File 'lib/ransack/helpers/form_helper.rb', line 112 def up_arrow Ransack.[:up_arrow] end |
#url_options ⇒ Object
131 132 133 134 135 |
# File 'lib/ransack/helpers/form_helper.rb', line 131 def @params.except(:host).merge( @options.except(:class, :data, :host).merge( @search.context.search_key => search_and_sort_params)) end |