Module: S3Browser::Store::StorePlugins::Base::ClassMethods

Included in:
S3Browser::Store
Defined in:
lib/s3browser/store.rb

Instance Method Summary collapse

Instance Method Details

#plugin(plugin, *args, &block) ⇒ Object

Load a new plugin into the current class. A plugin can be a module which is used directly, or a symbol represented a registered plugin which will be required and then used. Returns nil.

Store.plugin PluginModule
Store.plugin :csrf

Raises:



62
63
64
65
66
67
68
69
70
# File 'lib/s3browser/store.rb', line 62

def plugin(plugin, *args, &block)
  raise StoreError, "Cannot add a plugin to a frozen Store class" if frozen?
  plugin = StorePlugins.load_plugin(plugin) if plugin.is_a?(Symbol)
  plugin.load_dependencies(self, *args, &block) if plugin.respond_to?(:load_dependencies)
  include(plugin::InstanceMethods) if defined?(plugin::InstanceMethods)
  extend(plugin::ClassMethods) if defined?(plugin::ClassMethods)
  plugin.configure(self, *args, &block) if plugin.respond_to?(:configure)
  nil
end