Module: Shrine::Plugins::Derivatives
- Defined in:
- lib/shrine/plugins/derivatives.rb
Overview
Documentation can be found on shrinerb.com/docs/plugins/derivatives
Defined Under Namespace
Modules: AttacherClassMethods, AttacherMethods, AttachmentMethods, ClassMethods, FileMethods, VersionsCompatibility
Constant Summary collapse
- NOOP_PROCESSOR =
-> (*) { Hash.new }
- LOG_SUBSCRIBER =
-> (event) do Shrine.logger.info "Derivatives (#{event.duration}ms) – #{{ processor: event[:processor], processor_options: event[:processor_options], uploader: event[:uploader], }.inspect}" end
Class Method Summary collapse
- .configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts) ⇒ Object
- .load_dependencies(uploader, versions_compatibility: false) ⇒ Object
Class Method Details
.configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/shrine/plugins/derivatives.rb', line 23 def self.configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts) uploader.opts[:derivatives] ||= { processors: {}, storage: proc { store_key } } uploader.opts[:derivatives].merge!(opts) # instrumentation plugin integration uploader.subscribe(:derivatives, &log_subscriber) if uploader.respond_to?(:subscribe) end |
.load_dependencies(uploader, versions_compatibility: false) ⇒ Object
17 18 19 20 21 |
# File 'lib/shrine/plugins/derivatives.rb', line 17 def self.load_dependencies(uploader, versions_compatibility: false, **) uploader.plugin :default_url AttacherMethods.prepend(VersionsCompatibility) if versions_compatibility end |