module Shrine::Plugins
Module in which all Shrine plugins should be stored. Also contains logic for registering and loading plugins.
Public Class Methods
# File lib/shrine/plugins.rb 29 def self.configure(plugin, uploader, ...) 30 return unless plugin.respond_to?(:configure) 31 32 plugin.configure(uploader, ...) 33 end
Delegate to the plugin’s load_dependencies method.
# File lib/shrine/plugins.rb 22 def self.load_dependencies(plugin, uploader, ...) 23 return unless plugin.respond_to?(:load_dependencies) 24 25 plugin.load_dependencies(uploader, ...) 26 end
Delegate to the plugin’s load_dependencies method.
Source
# File lib/shrine/plugins.rb 13 def self.load_plugin(name) 14 unless plugin = @plugins[name] 15 require "shrine/plugins/#{name}" 16 raise Error, "plugin #{name} did not register itself correctly in Shrine::Plugins" unless plugin = @plugins[name] 17 end 18 plugin 19 end
If the registered plugin already exists, use it. Otherwise, require it and return it. This raises a LoadError if such a plugin doesn’t exist, or a Shrine::Error if it exists but it does not register itself correctly.
Source
# File lib/shrine/plugins.rb 39 def self.register_plugin(name, mod) 40 @plugins[name] = mod 41 end
Register the given plugin with Shrine, so that it can be loaded using Shrine.plugin with a symbol. Should be used by plugin files. Example:
Shrine::Plugins.register_plugin(:plugin_name, PluginModule)