Class: Paperclip::TempfileFactory

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

Instance Method Summary collapse

Instance Method Details

#basenameObject



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

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

#extensionObject



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

def extension
  File.extname(@name)
end

#generate(name = random_name) ⇒ Object



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

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

#random_nameObject



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

def random_name
  SecureRandom.uuid
end