lib/attached/attachment.rb in attached-0.1.7 vs lib/attached/attachment.rb in attached-0.1.8
- old
+ new
@@ -34,10 +34,11 @@
def self.options
@options ||= {
:path => "/:name/:style/:identifier:extension",
:default => :original,
+ :medium => :aws,
:credentials => {},
:styles => {},
:processors => [],
:aliases => [],
}
@@ -108,18 +109,16 @@
def assign(file, identifier = Guid.new)
@file = file.respond_to?(:tempfile) ? file.tempfile : file
extension ||= File.extname(file.original_filename) if file.respond_to?(:original_filename)
- extension ||= File.extname(file.path)
+ extension ||= File.extname(file.path) if file.respond_to?(:path)
instance_set :size, file.size
instance_set :extension, extension
instance_set :identifier, identifier
- self.queue[self.default] = self.file
-
process
end
# Save an attachment.
@@ -258,16 +257,18 @@
end
private
- # Helper function for calling processors.
+ # Helper function for calling processors (will queue default).
#
# Usage:
#
# self.process
def process
+ self.queue[self.default] = self.file
+
self.processors.each do |processor|
self.styles.each do |style, options|
case processor
when :image then self.queue[style] = Attached::Image.process(self.queue[style] || self.file, options, self)
end
\ No newline at end of file