module CodeRay::Plugin

Plugin

Plugins have to include this module.

IMPORTANT: Use extend for this module.

See CodeRay::PluginHost for examples.

Attributes

plugin_id[R]

Public Instance Methods

aliases() click to toggle source
# File lib/coderay/helpers/plugin.rb, line 273
def aliases
  plugin_host.load_plugin_map
  plugin_host.plugin_hash.inject [] do |aliases, (key, _)|
    aliases << key if plugin_host[key] == self
    aliases
  end
end
plugin_host(host = nil) click to toggle source

The PluginHost for this Plugin class.

# File lib/coderay/helpers/plugin.rb, line 266
def plugin_host host = nil
  if host.is_a? PluginHost
    const_set :PLUGIN_HOST, host
  end
  self::PLUGIN_HOST
end
register_for(id) click to toggle source

Register this class for the given id.

Example:

class MyPlugin < PluginHost::BaseClass
  register_for :my_id
  ...
end

See CodeRay::PluginHost#register.

# File lib/coderay/helpers/plugin.rb, line 250
def register_for id
  @plugin_id = id
  plugin_host.register self, id
end
title(title = nil) click to toggle source

Returns the title of the plugin, or sets it to the optional argument title.

# File lib/coderay/helpers/plugin.rb, line 257
def title title = nil
  if title
    @title = title.to_s
  else
    @title ||= name[%r([^:]+)$/, 1]
  end
end