lib/attached/attachment.rb in attached-0.1.6 vs lib/attached/attachment.rb in attached-0.1.7
- old
+ new
@@ -105,12 +105,13 @@
# Usage:
#
# @object.avatar.assign(...)
def assign(file, identifier = Guid.new)
- @file = file.tempfile
+ @file = file.respond_to?(:tempfile) ? file.tempfile : file
- extension = File.extname(file.original_filename)
+ extension ||= File.extname(file.original_filename) if file.respond_to?(:original_filename)
+ extension ||= File.extname(file.path)
instance_set :size, file.size
instance_set :extension, extension
instance_set :identifier, identifier
\ No newline at end of file