Module: Jamf::Lockable
- Included in:
- Prestage, PrestageLocation, PrestagePurchasingData, PrestageScope
- Defined in:
- lib/jamf/api/mixins/lockable.rb
Overview
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.
Instance Attribute Summary collapse
-
#versionLock ⇒ Object
readonly
Returns the value of attribute versionLock.
Instance Method Summary collapse
Instance Attribute Details
#versionLock ⇒ Object (readonly)
Returns the value of attribute versionLock.
41 42 43 |
# File 'lib/jamf/api/mixins/lockable.rb', line 41 def versionLock @versionLock end |
Instance Method Details
#initialize(data, cnx: Jamf.cnx) ⇒ Object
43 44 45 46 |
# File 'lib/jamf/api/mixins/lockable.rb', line 43 def initialize(data, cnx: Jamf.cnx) @versionLock = data[:versionLock] super end |
#to_jamf ⇒ Object
48 49 50 51 52 |
# File 'lib/jamf/api/mixins/lockable.rb', line 48 def to_jamf data = super data[:versionLock] = @versionLock data end |