Module: Jamf::Lockable
- Defined in:
- lib/jamf/api/jamf_pro/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.
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#versionLock ⇒ Object
readonly
module class methods.
Class Method Summary collapse
-
.included(includer) ⇒ Object
when this module is included, also extend our Class Methods.
Instance Method Summary collapse
Instance Attribute Details
#versionLock ⇒ Object (readonly)
module class methods
63 64 65 |
# File 'lib/jamf/api/jamf_pro/mixins/lockable.rb', line 63 def versionLock @versionLock end |
Class Method Details
.included(includer) ⇒ Object
when this module is included, also extend our Class Methods
44 45 46 47 |
# File 'lib/jamf/api/jamf_pro/mixins/lockable.rb', line 44 def self.included(includer) Jamf.load_msg "--> #{includer} is including Jamf::Lockable" includer.extend(ClassMethods) end |
Instance Method Details
#initialize(**data) ⇒ Object
65 66 67 68 |
# File 'lib/jamf/api/jamf_pro/mixins/lockable.rb', line 65 def initialize(**data) @versionLock = data[:versionLock] super(**data) end |
#lockable? ⇒ Boolean
76 77 78 |
# File 'lib/jamf/api/jamf_pro/mixins/lockable.rb', line 76 def lockable? self.class.lockable? end |
#to_jamf ⇒ Object
70 71 72 73 74 |
# File 'lib/jamf/api/jamf_pro/mixins/lockable.rb', line 70 def to_jamf data = super data[:versionLock] = @versionLock data end |