module Shrine::Plugins::DerivationEndpoint

  1. lib/shrine/plugins/derivation_endpoint.rb

Documentation can be found on shrinerb.com/docs/plugins/derivation_endpoint

Methods

Public Class

  1. configure
  2. load_dependencies

Constants

LOG_SUBSCRIBER = -> (event) do Shrine.logger.info "Derivation (#{event.duration}ms) – #{{ name: event[:derivation].name, args: event[:derivation].args, uploader: event[:uploader], }.inspect}" end  

Public Class methods

configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts)
[show source]
   # File lib/shrine/plugins/derivation_endpoint.rb
27 def self.configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts)
28   uploader.opts[:derivation_endpoint] ||= { options: {}, derivations: {} }
29   uploader.opts[:derivation_endpoint][:options].merge!(opts)
30 
31   if !uploader.opts[:derivation_endpoint][:options][:secret_key] && !uploader.opts[:derivation_endpoint][:options][:signer]
32     fail Error, "must provide :secret_key option to derivation_endpoint plugin when no custom signer is set"
33   end
34 
35   # instrumentation plugin integration
36   uploader.subscribe(:derivation, &log_subscriber) if uploader.respond_to?(:subscribe)
37 end
load_dependencies(uploader, **)
[show source]
   # File lib/shrine/plugins/derivation_endpoint.rb
22 def self.load_dependencies(uploader, **)
23   uploader.plugin :rack_response
24   uploader.plugin :_urlsafe_serialization
25 end