Module: PresignedUpload::Models
- Defined in:
- lib/presigned_upload/models.rb
Overview
Module extended by ActiveRecord::Base to allow configuring models with resources of the gem
Instance Method Summary collapse
-
#presigned_uploadable ⇒ Object
Calling this method in the context of the model class includes Uploadable module, which makes available the methods for requesting presigned_urls and deleting file from the cloud storage.
-
#presigned_uploadable_model(options = {}) ⇒ Object
Calling this method in the context of the model class includes Uploadable::Model module, which includes all the behavior from the Uploadable module and the Uploadable::Model, including validations and callbacks.
Instance Method Details
#presigned_uploadable ⇒ Object
Calling this method in the context of the model class includes Uploadable module, which makes available the methods for requesting presigned_urls and deleting file from the cloud storage
@example:
UploadLink < ApplicationRecord
presigned_uploadable
end
upload_link = UploadLink.new
upload_link.presigned_url('key', :get, expires_in = 3600)
upload_link.delete_file('key')
24 25 26 |
# File 'lib/presigned_upload/models.rb', line 24 def presigned_uploadable include Uploadable end |
#presigned_uploadable_model(options = {}) ⇒ Object
Calling this method in the context of the model class includes Uploadable::Model module, which includes all the behavior from the Uploadable module and the Uploadable::Model, including validations and callbacks
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/presigned_upload/models.rb', line 44 def presigned_uploadable_model( = {}) include Uploadable::Model store_dir = [:store_dir] define_method :store_dir do case store_dir when Symbol __send__(store_dir) when String store_dir when Proc instance_exec(&store_dir) else "uploads/#{model_name.plural}/#{id}" end end end |