From b65c97e49e34b2925816372d58903d3e40030964 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Wed, 6 Jan 2016 00:14:38 +0100 Subject: [PATCH] Remove inline conditional from constructor back to private method Follow-up to #634. --- lib/ransack/helpers/form_helper.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ransack/helpers/form_helper.rb b/lib/ransack/helpers/form_helper.rb index 57d0d9b4f..aa2e2a0dd 100644 --- a/lib/ransack/helpers/form_helper.rb +++ b/lib/ransack/helpers/form_helper.rb @@ -86,7 +86,7 @@ def url(routing_proxy, options_for_url) 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 @@ def html_options(args) 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]