Method: Jamf::Categorizable#category=

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

#category=(new_cat) ⇒ void

This method returns an undefined value.

Change the category of this object. Any of the NON_CATEGORIES values will unset the category

Parameters:

  • new_cat (Integer, String)

    The new category

Raises:



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/jamf/api/classic/api_objects/categorizable.rb', line 132

def category=(new_cat)
  return nil unless updatable? || creatable?

  # unset the category? Use nil or an empty string
  if NON_CATEGORIES.include? new_cat
    unset_category
    return
  end

  new_name, new_id = evaluate_new_category(new_cat)

  # no change, go home.
  return nil if new_name == @category_name

  raise Jamf::NoSuchItemError, "Category '#{new_cat}' is not known to the JSS" unless Jamf::Category.all_names(:ref, cnx: @cnx).include? new_name

  @category_name = new_name
  @category_id = new_id
  @need_to_update = true
end