Class: Paperclip::TempfileFactory

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) basename



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

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

- (Object) extension



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

def extension
  File.extname(@name)
end

- (Object) generate(name = random_name)



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

- (Object) random_name



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

def random_name
  SecureRandom.uuid
end