Rename `FileHelper.images` to `FileHelper.supported_images`.

This commit is contained in:
Guo Xiang Tan 2018-09-10 10:03:44 +08:00
parent 02f582eca0
commit d59e635a77
2 changed files with 5 additions and 7 deletions

View File

@ -100,14 +100,12 @@ class FileHelper
).optimize_image!(filename) ).optimize_image!(filename)
end end
private def self.supported_images
@@supported_images ||= Set.new %w{jpg jpeg png gif tif tiff bmp svg webp ico}
def self.images
@@images ||= Set.new %w{jpg jpeg png gif tif tiff bmp svg webp ico}
end end
def self.images_regexp def self.images_regexp
@@images_regexp ||= /\.(#{images.to_a.join("|")})$/i @@images_regexp ||= /\.(#{supported_images.to_a.join("|")})$/i
end end
end end

View File

@ -74,11 +74,11 @@ class Validators::UploadValidator < ActiveModel::Validator
end end
def authorized_images(upload) def authorized_images(upload)
authorized_extensions(upload) & FileHelper.images authorized_extensions(upload) & FileHelper.supported_images
end end
def authorized_attachments(upload) def authorized_attachments(upload)
authorized_extensions(upload) - FileHelper.images authorized_extensions(upload) - FileHelper.supported_images
end end
def authorizes_all_extensions?(upload) def authorizes_all_extensions?(upload)