Module: JSS::Scopable

Included in:
ConfigurationProfile, MacApplication, MobileDeviceApplication, PatchPolicy, Policy, RestrictedSoftware
Defined in:
lib/jss/api_object/scopable.rb,
lib/jss.rb,
lib/jss/api_object/scopable/scope.rb

Overview

A mix-in module for handling scoping data for objects in the JSS.

The JSS objects that can be scoped use similar data to represent that scoping. This module provides a consistant way to deal with scoping data via some instance methods and the Scope class.

When this module is mixed in to a APIObject subclass, instances of the subclass will have a @scope attribute containing a Scope instance

Classes that mix in this module must:

  • Set a Constant SCOPE_TARGET_KEY that is either :computers or :mobile_devices

  • Include the result of self.scope.scope_xml in their own rest_xml output if they are Updatable or Creatable

Defined Under Namespace

Classes: Scope

Constant Summary collapse

SCOPABLE =

Constants

true

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#scopeObject

Attribtues



65
66
67
# File 'lib/jss/api_object/scopable.rb', line 65

def scope
  @scope
end

Instance Method Details

#parse_scopevoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Call this during initialization of objects that have a scope and the scope instance will be created from @init_data



77
78
79
80
# File 'lib/jss/api_object/scopable.rb', line 77

def parse_scope
  @scope = JSS::Scopable::Scope.new self.class::SCOPE_TARGET_KEY, @init_data[:scope]
  @scope.container = self
end

#should_updatevoid

This method returns an undefined value.

When the scope changes, it calls this to tell us that an update is needed.



99
100
101
# File 'lib/jss/api_object/scopable.rb', line 99

def should_update
  @need_to_update = true if @in_jss
end

#updateObject

A wrapper around the update method, to try catching 409 conflict errors when we couldn't verify all ldap users/groups due to lack of ldap connections



106
107
108
109
110
111
112
113
114
# File 'lib/jss/api_object/scopable.rb', line 106

def update
  super
rescue JSS::ConflictError => conflict
  if scope.unable_to_verify_ldap_entries == true
    raise JSS::InvalidDataError, "Potentially non-existant LDAP user or group in new scope values."
  else
    raise conflict
  end
end