Public method hooks for the order arrow defs

and inline the conditional.
This commit is contained in:
Jon Atack 2016-07-23 13:01:23 +02:00
parent c0dff3384c
commit e489ca7789
1 changed files with 13 additions and 9 deletions

View File

@ -97,6 +97,14 @@ module Ransack
@default_order = @options.delete :default_order
end
def up_arrow
'▼'.freeze
end
def down_arrow
'▲'.freeze
end
def name
[ERB::Util.h(@label_text), order_indicator]
.compact
@ -190,21 +198,17 @@ module Ransack
def order_indicator
return if @hide_indicator || no_sort_direction_specified?
direction_arrow
if @current_dir == 'desc'.freeze
up_arrow
else
down_arrow
end
end
def no_sort_direction_specified?(dir = @current_dir)
!['asc'.freeze, 'desc'.freeze].freeze.include?(dir)
end
def direction_arrow
if @current_dir == 'desc'.freeze
'▼'.freeze
else
'▲'.freeze
end
end
def direction_text(dir)
return 'asc'.freeze if dir == 'desc'.freeze
'desc'.freeze