Method: Jamf::Categorizable#evaluate_new_category

Defined in:
lib/jamf/api/classic/api_objects/categorizable.rb

#evaluate_new_category(new_cat) ⇒ Array<String, Integer>

Given a category name or id, return the name and id TODO: use APIObject.exist? and/or APIObject.valid_id

Parameters:

  • new_cat (String, Integer)

    The name or id of a possible category

Returns:

  • (Array<String, Integer>)

    The matching name and id, which may be nil.



159
160
161
162
163
164
165
166
167
168
169
# File 'lib/jamf/api/classic/api_objects/categorizable.rb', line 159

def evaluate_new_category(new_cat)
  # if we were given anything but a string, assume it was an id.
  if new_cat.is_a? String
    new_name = new_cat
    new_id = Jamf::Category.category_id_from_name new_cat, cnx: @cnx
  else
    new_id = new_cat
    new_name = Jamf::Category.map_all_ids_to(:name, cnx: @cnx)[new_id]
  end
  [new_name, new_id]
end