Class: Paperclip::TempfileFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/paperclip/tempfile_factory.rb

Instance Method Summary collapse

Instance Method Details

#basenameObject



14
15
16
# File 'lib/paperclip/tempfile_factory.rb', line 14

def basename
  Digest::MD5.hexdigest(File.basename(@name, extension))
end

#extensionObject



10
11
12
# File 'lib/paperclip/tempfile_factory.rb', line 10

def extension
  File.extname(@name)
end

#generate(name = random_name) ⇒ Object



3
4
5
6
7
8
# File 'lib/paperclip/tempfile_factory.rb', line 3

def generate(name = random_name)
  @name = name
  file = Tempfile.new([basename, extension])
  file.binmode
  file
end

#random_nameObject



18
19
20
# File 'lib/paperclip/tempfile_factory.rb', line 18

def random_name
  SecureRandom.uuid
end