Module: ObjectStorage::Extension::RecordsUploads
- Extended by:
- ActiveSupport::Concern
- Included in:
- AttachmentUploader, AvatarUploader, DesignManagement::DesignV432x230Uploader, FileUploader, MetricImageUploader
- Defined in:
- app/uploaders/object_storage.rb
Overview
this extension is the glue between the ObjectStorage::Concern and RecordsUploads::Concern
Instance Method Summary collapse
- #build_upload ⇒ Object
- #exclusive_lease_key ⇒ Object
- #retrieve_from_store!(identifier) ⇒ Object
- #upload=(upload) ⇒ Object
Instance Method Details
#build_upload ⇒ Object
94 95 96 97 98 |
# File 'app/uploaders/object_storage.rb', line 94 def build_upload super.tap do |upload| upload.store = object_store end end |
#exclusive_lease_key ⇒ Object
107 108 109 110 111 112 113 114 |
# File 'app/uploaders/object_storage.rb', line 107 def exclusive_lease_key # For FileUploaders, model may have many uploaders. In that case # we want to use exclusive key per upload, not per model to allow # parallel migration key_object = upload || model "object_storage_migrate:#{key_object.class}:#{key_object.id}" end |
#retrieve_from_store!(identifier) ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'app/uploaders/object_storage.rb', line 83 def retrieve_from_store!(identifier) paths = upload_paths(identifier) unless current_upload_satisfies?(paths, model) # the upload we already have isn't right, find the correct one self.upload = model&.retrieve_upload(identifier, paths) end super end |
#upload=(upload) ⇒ Object
100 101 102 103 104 105 |
# File 'app/uploaders/object_storage.rb', line 100 def upload=(upload) return if upload.nil? self.object_store = upload.store super end |