Module: Jamf::Sortable

Defined in:
lib/jamf/api/jamf_pro/mixins/sortable.rb

Overview

Currently no need to mix this in anywhere.

Constant Summary collapse

SORT_PARAM_PREFIX =
'&sort='.freeze

Class Method Summary collapse

Class Method Details

.parse_url_sort_param(sort) ⇒ Object

generate the sort params for the url This is callable from anywhere without mixing in



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/jamf/api/jamf_pro/mixins/sortable.rb', line 34

def self.parse_url_sort_param(sort)
  return sort if sort.nil? || sort.start_with?(SORT_PARAM_PREFIX)

  case sort
  when String
    "&sort=#{CGI.escape sort}"
  when Array
    "&sort=#{CGI.escape sort.join(',')}"
  else
    raise ArgumentError, 'sort criteria must be a String or Array of Strings'
  end
end