media file: memoize expensive methods in subclasses.
This commit is contained in:
@@ -113,5 +113,5 @@ class MediaFile
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
memoize :dimensions, :file_ext, :file_size, :md5, :is_corrupt?, :is_animated?
|
memoize :file_ext, :file_size, :md5
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -54,5 +54,6 @@ class MediaFile::Flash < MediaFile
|
|||||||
|
|
||||||
[width, height]
|
[width, height]
|
||||||
end
|
end
|
||||||
|
|
||||||
memoize :dimensions
|
memoize :dimensions
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ class MediaFile::Image < MediaFile
|
|||||||
end
|
end
|
||||||
|
|
||||||
def image
|
def image
|
||||||
@image ||= Vips::Image.new_from_file(file.path, fail: true)
|
Vips::Image.new_from_file(file.path, fail: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
memoize :image, :dimensions, :is_corrupt?, :is_animated_gif?, :is_animated_png?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -88,5 +88,5 @@ class MediaFile::Ugoira < MediaFile
|
|||||||
MediaFile.open(tempfile)
|
MediaFile.open(tempfile)
|
||||||
end
|
end
|
||||||
|
|
||||||
memoize :zipfile, :preview_frame
|
memoize :zipfile, :preview_frame, :dimensions
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,5 +31,5 @@ class MediaFile::Video < MediaFile
|
|||||||
MediaFile.open(vp.path)
|
MediaFile.open(vp.path)
|
||||||
end
|
end
|
||||||
|
|
||||||
memoize :video, :preview_frame
|
memoize :video, :preview_frame, :dimensions, :duration, :has_audio?
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user