Method: Doing::Plugins.validate_plugin

Defined in:
lib/doing/plugin_manager.rb

.validate_plugin(title, type, klass) ⇒ Object

Verifies that a plugin is properly configured with necessary methods for its type. If the plugin fails validation, a PluginUncallable exception will be raised.

Parameters:

  • title (String)

    The title

  • type (Symbol)

    type, :import or :export

  • klass (Class)

    Plugin class



102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/doing/plugin_manager.rb', line 102

def validate_plugin(title, type, klass)
  type = valid_type(type)
  if type == :import && !klass.respond_to?(:import)
    raise Errors::PluginUncallable.new('Import plugins must respond to :import', type, title)
  end

  if type == :export && !klass.respond_to?(:render)
    raise Errors::PluginUncallable.new('Export plugins must respond to :render', type, title)
  end

  type
end