class Shrine::Plugins::KitheDerivativeDefinitions
Public Class Methods
configure(uploader, *opts)
click to toggle source
# File lib/shrine/plugins/kithe_derivative_definitions.rb, line 4 def self.configure(uploader, *opts) # use Rails class_attribute to conveniently have a class-level place # to store our derivative definitions that are inheritable and overrideable. # We store it on the Attacher class, because that's where shrine # puts derivative processor definitions, so seems appropriate. uploader::Attacher.class_attribute :kithe_derivative_definitions, instance_writer: false, default: [] # Register our derivative processor, that will create our registered derivatives, # with our custom options. uploader::Attacher.derivatives(:kithe_derivatives) do |original, **options| Kithe::Asset::DerivativeCreator.new(self.class.kithe_derivative_definitions, source_io: original, shrine_attacher: self, only: options[:only], except: options[:except], lazy: options[:lazy] ).call end end