Skip to content

Commit

Permalink
Remove inline conditional from constructor back to private method
Browse files Browse the repository at this point in the history
Follow-up to #634.
  • Loading branch information
jonatack committed Jan 5, 2016
1 parent e320178 commit b65c97e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/ransack/helpers/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit b65c97e

Please sign in to comment.