Class: Staticky::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/staticky/resource.rb

Class Method Summary collapse

Class Method Details

.plugin(plugin) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/staticky/resource.rb', line 5

def self.plugin(plugin, ...)
  plugin = Resources::Plugins.load_plugin(plugin) if plugin.is_a?(Symbol)
  unless plugin.is_a?(Module)
    raise ArgumentError, "Invalid plugin type: #{plugin.class.inspect}"
  end

  if plugin.respond_to?(:load_dependencies)
    plugin.load_dependencies(self, ...)
  end

  include plugin::InstanceMethods if defined?(plugin::InstanceMethods)
  extend plugin::ClassMethods if defined?(plugin::ClassMethods)

  plugin.configure(self, ...) if plugin.respond_to?(:configure)
end