Remove inline conditional from constructor back to private method

Follow-up to #634.
This commit is contained in:
Jon Atack 2016-01-06 00:14:38 +01:00
parent e32017842d
commit b65c97e49e
1 changed files with 6 additions and 1 deletions

View File

@ -86,7 +86,7 @@ module Ransack
class SortLink
def initialize(search, attribute, args, params)
@search = search
@params = params.respond_to?(:to_unsafe_h) ? params.to_unsafe_h : params
@params = parameters_hash(params)
@field = attribute.to_s
@sort_fields = extract_sort_fields_and_mutate_args!(args).compact
@current_dir = existing_sort_direction
@ -120,6 +120,11 @@ module Ransack
private
def parameters_hash(params)
return params unless params.respond_to?(:to_unsafe_h)
params.to_unsafe_h
end
def extract_sort_fields_and_mutate_args!(args)
return args.shift if args[0].is_a?(Array)
[@field]