—
title: Shrine
3.1.0¶ ↑
New features¶ ↑
-
The
Attacher#create_derivatives
method now accepts a:storage
option for specifying the storage to which derivatives should be uploaded.
“‘rb # with attachment module photo.image_derivatives!(storage: :other_store)
# with attacher attacher.create_derivatives(storage: :other_store) “‘
-
The
Shrine.calculate_signature
now accepts a:rewind
boolean option for choosing whether the IO object should be rewinded after reading. This is useful if you want to calculate signature from non-rewindable IO objects, such asIO.pipe
,Socket
, non-rewindableDown::ChunkedIO
etc.
rb Shrine.signature(io, rewind: false)
Improvements¶ ↑
-
The derivatives processor can now be registered with
Attacher.derivatives
, which is just an alias forAttacher.derivatives_processor
.
“‘rb class ImageUploader < Shrine
Attacher.derivatives_processor do |original| # … end end
# can now be written as
class ImageUploader < Shrine
Attacher.derivatives do |original| # … end end “‘
-
The
Attacher#cached?
andAttacher#stored?
methods now work correctly if temporary/permanent storage identifiers were specified as strings. -
The
store_dimensions
plugin now properly propagates exceptions when loading theruby-vips
gem in:vips
analyzer. -
The
add_metadata
plugin now respects inheritance again when defining metadata methods on theShrine::UploadedFile
class. In 2.19.0, theadd_metadata
plugin was changed to define metadata methods on the internalFileMethods
plugin module, which is shared across all uploaders. This change has now been reverted.
Backwards compatibility¶ ↑
-
The
Attacher#cache_key
andAttacher#store_key
methods now always return symbol keys, even if the storage key that was specified was a string key.
rb attacher = Shrine::Attacher.new(cache: "cache", store: "store") attacher.cache_key #=> :cache (previously "cache") attacher.store_key #=> :store (previously "store")
-
The
add_metadata
plugin now defines metadata methods directly on theUploadedFile
class, which means that if you happen to have been overriding these metadata methods and callingsuper
, this won’t work anymore.