lib/jamf/api/classic/api_objects/scopable.rb in ruby-jss-3.1.0 vs lib/jamf/api/classic/api_objects/scopable.rb in ruby-jss-3.2.0b3
- old
+ new
@@ -73,23 +73,28 @@
### and the scope instance will be created from @init_data
###
### @return [void]
###
def parse_scope
- @scope = Jamf::Scopable::Scope.new self.class::SCOPE_TARGET_KEY, @init_data[:scope]
- @scope.container = self
+ @scope = Jamf::Scopable::Scope.new self.class::SCOPE_TARGET_KEY, @init_data[:scope], container: self
+ @scope.container ||= self
end
### Change the scope
###
### @param new_scope[Jamf::Scopable::Scope] the new scope
###
### @return [void]
###
- def scope= (new_scope)
- raise Jamf::InvalidDataError, "Jamf::Scopable::Scope instance required" unless new_criteria.kind_of?(Jamf::Scopable::Scope)
- raise Jamf::InvalidDataError, "Scope object must have target_key of :#{self.class::SCOPE_TARGET_KEY}" unless self.class::SCOPE_TARGET_KEY == new_scope.target_key
+ def scope=(new_scope)
+ raise Jamf::InvalidDataError, 'Jamf::Scopable::Scope instance required' unless new_criteria.is_a?(Jamf::Scopable::Scope)
+
+ unless self.class::SCOPE_TARGET_KEY == new_scope.target_key
+ raise Jamf::InvalidDataError,
+ "Scope object must have target_key of :#{self.class::SCOPE_TARGET_KEY}"
+ end
+
@scope = new_scope
@need_to_update = true
end
### When the scope changes, it calls this to tell us that an update is needed.
@@ -103,15 +108,15 @@
# 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
#
def update
super
- rescue Jamf::ConflictError => conflict
- if scope.unable_to_verify_ldap_entries == true
- raise Jamf::InvalidDataError, "Potentially non-existant LDAP user or group in new scope values."
- else
- raise conflict
- end
+ @scope.should_update = false
+ rescue Jamf::ConflictError => e
+ raise Jamf::InvalidDataError, 'Potentially non-existant LDAP user or group in new scope values.' if scope.unable_to_verify_ldap_entries == true
+
+ raise e
end # update
end # module Scopable
+
end # module Jamf