Class: AsyncPaperclipUploader::Temporary
- Inherits:
-
Object
- Object
- AsyncPaperclipUploader::Temporary
- Defined in:
- lib/async_paperclip_uploader/temporary.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(object, attribute, uploaded_file) ⇒ Temporary
constructor
A new instance of Temporary.
- #valid? ⇒ Boolean
- #valid_attachment? ⇒ Boolean
- #valid_class_attr? ⇒ Boolean
Constructor Details
#initialize(object, attribute, uploaded_file) ⇒ Temporary
Returns a new instance of Temporary.
3 4 5 6 7 |
# File 'lib/async_paperclip_uploader/temporary.rb', line 3 def initialize(object, attribute, uploaded_file) @object = object @attribute = attribute @uploaded_file = uploaded_file end |
Class Method Details
.base_path ⇒ Object
35 36 37 |
# File 'lib/async_paperclip_uploader/temporary.rb', line 35 def self.base_path ENV["FILE_UPLOAD_STAGING_DIR"] end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 |
# File 'lib/async_paperclip_uploader/temporary.rb', line 9 def call if valid? upload run_permanent_upload_job end end |
#valid? ⇒ Boolean
16 17 18 |
# File 'lib/async_paperclip_uploader/temporary.rb', line 16 def valid? valid_class_attr? && end |
#valid_attachment? ⇒ Boolean
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/async_paperclip_uploader/temporary.rb', line 24 def = { :filename => @uploaded_file[:filename], :content_type => @uploaded_file[:type], :headers => @uploaded_file[:head], :tempfile => @uploaded_file[:tempfile] } @object.send("#{@attribute}=", ActionDispatch::Http::UploadedFile.new()) @object.valid? end |
#valid_class_attr? ⇒ Boolean
20 21 22 |
# File 'lib/async_paperclip_uploader/temporary.rb', line 20 def valid_class_attr? @object.respond_to?(@attribute.to_sym) end |