Skip to content

Commit

Permalink
Replace arrow constants with frozen strings
Browse files Browse the repository at this point in the history
These constants are only used once in the code base and constant lookup
is slower than frozen strings in MRI Ruby 2.2+.
  • Loading branch information
jonatack committed Jul 23, 2016
1 parent 5280ecf commit c0dff33
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 0 additions & 3 deletions lib/ransack/constants.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
module Ransack
module Constants
ASC_ARROW = '▲'.freeze
DESC_ARROW = '▼'.freeze

OR = 'or'.freeze
AND = 'and'.freeze

Expand Down
7 changes: 5 additions & 2 deletions lib/ransack/helpers/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,11 @@ def no_sort_direction_specified?(dir = @current_dir)
end

def direction_arrow
return Constants::DESC_ARROW if @current_dir == 'desc'.freeze
Constants::ASC_ARROW
if @current_dir == 'desc'.freeze
'▼'.freeze
else
'▲'.freeze
end
end

def direction_text(dir)
Expand Down

0 comments on commit c0dff33

Please sign in to comment.