lib/jss/api_object/scopable/scope.rb
def add_target(key, item)
        key = pluralize_key(key)
        item_id = validate_item(:target, key, item)
        return if @targets[key]&.include?(item_id)

        raise JSS::AlreadyExistsError, "Can't set #{key} target to '#{item}' because it's already an explicit exclusion." if @exclusions[key]&.include?(item_id)

        @targets[key] << item_id
        @all_targets = false
        @container&.should_update
      end
# Add a single item as a target in this scope.
#
# The item name will be checked for existence in the JSS, and an exception
#  raised if the item doesn't exist.
#
# @param key[Symbol] the key from #{SCOPING_CLASSES} for the kind of item being added, :computer, :building, etc...
#
# @param item[String,integer] a valid identifier of the item being added
#
# @example
#   add_target(:computers, "mantis")
#
# @example
#   add_target(:computer_groups, 2342)
#
# @return [void]
#
Add a single item as a target in this scope.
The item name will be checked for existence in the JSS, and an exception
raised if the item doesn't exist.
Add a single item as a target in this scope . The item name will be checked for existence in the JSS and an exception raised if the item doesn ' t exist .
def add_target(key, item)
        key = pluralize_key(key)
        item_id = validate_item(:target, key, item)
        return if @targets[key]&.include?(item_id)
        raise JSS::AlreadyExistsError, "Can't set #{key} target to '#{item}' because it's already an explicit exclusion." if @exclusions[key]&.include?(item_id)
        @targets[key] << item_id
        @all_targets = false
        @container&.should_update
      end
def add_target ( key , item ) key = pluralize_key ( key ) item_id = validate_item ( :target , key , item ) return if @targets [ key ] &. include? ( item_id ) raise JSS :: AlreadyExistsError , "Can't set #{key} target to '#{item}' because it's already an explicit exclusion." if @exclusions [ key ] &. include? ( item_id ) @targets [ key ] << item_id @all_targets = false @container &. should_update end
Add a single item as a target in this scope.
Add a single item as a target in this scope .
None
void
key
the key from #{SCOPING_CLASSES} for the kind of item being added, :computer, :building, etc
the key from # { SCOPING_CLASSES } for the kind of item being added : computer : building etc
item
a valid identifier of the item being added
a valid identifier of the item being added
example
None
example
None