Sha256: b8a2fb612580fbe448c1fe1bc51bc777731e91ddabf2279aa0e0008cc74b6b09

Contents?: true

Size: 668 Bytes

Versions: 3

Compression:

Stored size: 668 Bytes

Contents

# frozen_string_literal: true

module Staticky
  class Resource
    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

    plugin :prelude
    plugin :phlex
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
staticky-0.3.1 lib/staticky/resource.rb
staticky-0.3.0 lib/staticky/resource.rb
staticky-0.2.0 lib/staticky/resource.rb