Commit ffb0e01b by Henrik N

Shorten !attachment.original_filename.blank? to attachment.file?

parent 71adf38c
......@@ -135,7 +135,7 @@ module Paperclip
end
define_method "#{name}?" do
! attachment_for(name).original_filename.blank?
attachment_for(name).file?
end
validates_each(name) do |record, attr, value|
......@@ -157,7 +157,8 @@ module Paperclip
unless options[:less_than].nil?
options[:in] = (0..options[:less_than])
end
unless attachment.original_filename.blank? || options[:in].include?(instance[:"#{name}_file_size"].to_i)
if attachment.file? && !options[:in].include?(instance[:"#{name}_file_size"].to_i)
min = options[:in].first
max = options[:in].last
......@@ -178,7 +179,7 @@ module Paperclip
# Places ActiveRecord-style validations on the presence of a file.
def validates_attachment_presence name, options = {}
attachment_definitions[name][:validations] << lambda do |attachment, instance|
if attachment.original_filename.blank?
unless attachment.file?
options[:message] || "must be set."
end
end
......
......@@ -188,6 +188,10 @@ module Paperclip
end
end
def file?
!original_filename.blank?
end
private
def logger
......@@ -249,7 +253,7 @@ module Paperclip
end
def queue_existing_for_delete #:nodoc:
return if original_filename.blank?
return unless file?
logger.info("[paperclip] Queueing the existing files for #{name} for deletion.")
@queued_for_delete += [:original, *@styles.keys].uniq.map do |style|
path(style) if exists?(style)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment