Class: Fash

Inherits:
File
  • Object
show all
Defined in:
lib/rmce_uploadr/core/fash.rb

Overview

A paperclip-like UpFile class

Paperclip checks for :original_filename and :content_type so, let’s giv’em to it

the other attributes are :to_tempfile and :size but those are handled by Mash’s :method_missing

Instance Method Summary collapse

Constructor Details

#initialize(rack_multipart) ⇒ Fash

rack_multipart is what you get when a multipart-encoded form is submitted

converts a standard rack multipart file upload to an object paperclip will understand



14
15
16
17
# File 'lib/rmce_uploadr/core/fash.rb', line 14

def initialize(rack_multipart)
  @original = rack_multipart
  super(rack_multipart.is_a?(String) ? rack_multipath : @original[:tempfile].path)
end

Instance Method Details

#content_typeObject



29
30
31
# File 'lib/rmce_uploadr/core/fash.rb', line 29

def content_type
  @original[:type] || paperclip_content_type
end

#original_filenameObject



24
25
26
# File 'lib/rmce_uploadr/core/fash.rb', line 24

def original_filename
  @original[:filename] || paperclip_original_filename
end

#paperclip_content_typeObject



28
# File 'lib/rmce_uploadr/core/fash.rb', line 28

alias :paperclip_content_type :content_type

#paperclip_original_filenameObject



23
# File 'lib/rmce_uploadr/core/fash.rb', line 23

alias :paperclip_original_filename :original_filename

#to_tempfileObject



19
20
21
# File 'lib/rmce_uploadr/core/fash.rb', line 19

def to_tempfile
  @original[:tempfile] || @original
end