Class: Batch
- Inherits:
-
ActiveFedora::Base
- Object
- ActiveFedora::Base
- Batch
- Extended by:
- Sufia::Lockable
- Includes:
- Hydra::AccessControls::Permissions, Sufia::ModelMethods, Sufia::Noid
- Defined in:
- app/models/batch.rb
Class Method Summary collapse
-
.find_or_create(id) ⇒ Object
This method handles most race conditions gracefully.
Methods included from Sufia::Lockable
acquire_lock_for, lock_manager
Methods included from Sufia::Noid
Methods included from Sufia::ModelMethods
Methods inherited from ActiveFedora::Base
#create_event, #events, #log_event, stream, #stream
Class Method Details
.find_or_create(id) ⇒ Object
This method handles most race conditions gracefully.
14 15 16 17 18 19 20 21 22 |
# File 'app/models/batch.rb', line 14 def self.find_or_create(id) acquire_lock_for(id) do begin Batch.find(id) rescue ActiveFedora::ObjectNotFoundError Batch.create(id: id) end end end |