module Shrine::Plugins::KitheMultiCache

Allows an uploader to have more than one 'cache' – although the main one registered as normal will ordinarily be used, you can manually assign UploadedFiles (or hashes) specifying other caches, and they will be accepted, and promoted.

Invented for use with shrine-url.

Shrine.storages = {
  cache: ...,
  store: ...,
  remote_url: Shrine::Storage::Url.new
 }

class SomeUploader < Shrine
  plugin :kithe_multi_cache, additional_cache: [:remote_url, :something_else]
  ...
end

Now in your model, you can

my_model.attached_file = { "id" => "http://example.com", "storage" => "remote_url"}

And the data can be saved, and the remote url (shrine-url) file will be promoted as usual, even though it's not registered as the cache storage.

Public Class Methods

configure(uploader, options = {}) click to toggle source
# File lib/shrine/plugins/kithe_multi_cache.rb, line 28
def self.configure(uploader, options = {})
  uploader.opts[:kithe_multi_cache_keys]  = Array(options[:additional_cache]).collect(&:to_sym)
end