module Jamf::Lockable

Classes mixing this in have a ‘versionLock’ attribute and implement ‘Optimistic Locking’

https://stackoverflow.com/questions/129329/optimistic-vs-pessimistic-locking/129397#129397

When the object is saved, the versionLock is sent back with the data and if it doesn’t match whats on the server, then the object has been updated from elsewhere since we fetched it, and a 409 Conflict error is raised with the reason OPTIMISTIC_LOCK_FAILED.

If that happens, the save doesnt happen, the object must be re-fetched, and the user can try again.

Attributes

versionLock[R]

Public Class Methods

included(includer) click to toggle source

when this module is included, also extend our Class Methods

   # File lib/jamf/api/jamf_pro/mixins/lockable.rb
44 def self.included(includer)
45   Jamf.load_msg "--> #{includer} is including Jamf::Lockable"
46   includer.extend(ClassMethods)
47 end
new(**data) click to toggle source
Calls superclass method
   # File lib/jamf/api/jamf_pro/mixins/lockable.rb
65 def initialize(**data)
66   @versionLock = data[:versionLock]
67   super(**data)
68 end

Public Instance Methods

lockable?() click to toggle source
   # File lib/jamf/api/jamf_pro/mixins/lockable.rb
76 def lockable?
77   self.class.lockable?
78 end
to_jamf() click to toggle source
Calls superclass method
   # File lib/jamf/api/jamf_pro/mixins/lockable.rb
70 def to_jamf
71   data = super
72   data[:versionLock] = @versionLock
73   data
74 end