Module: Shrine::Plugins::RemoteUrl
- Defined in:
- lib/shrine/plugins/remote_url.rb
Overview
Documentation lives in [doc/plugins/remote_url.md] on GitHub.
[doc/plugins/remote_url.md]: github.com/shrinerb/shrine/blob/master/doc/plugins/remote_url.md
Defined Under Namespace
Modules: AttacherMethods, AttachmentMethods, ClassMethods
Constant Summary collapse
- LOG_SUBSCRIBER =
-> (event) do Shrine.logger.info "Remote URL (#{event.duration}ms) – #{{ remote_url: event[:remote_url], download_options: event[:download_options], uploader: event[:uploader], }.inspect}" end
Class Method Summary collapse
Class Method Details
.configure(uploader, opts = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/shrine/plugins/remote_url.rb', line 19 def self.configure(uploader, opts = {}) uploader.opts[:remote_url] ||= { downloader: Down.method(:download), log_subscriber: LOG_SUBSCRIBER } uploader.opts[:remote_url].merge!(opts) unless uploader.opts[:remote_url].key?(:max_size) fail Error, "The :max_size option is required for remote_url plugin" end # instrumentation plugin integration if uploader.respond_to?(:subscribe) uploader.subscribe(:remote_url, &uploader.opts[:remote_url][:log_subscriber]) end end |