Sha256: 1cc7bacb7d587b8cee44eece323c3669c07c6a6d98239de54b7d2d17a1e70e1f

Contents?: true

Size: 1.11 KB

Versions: 6605

Compression:

Stored size: 1.11 KB

Contents

module CodeRay
  
  # = Plugin
  #
  #  Plugins have to include this module.
  #
  #  IMPORTANT: Use extend for this module.
  #
  #  See CodeRay::PluginHost for examples.
  module Plugin
    
    attr_reader :plugin_id
    
    # Register this class for the given +id+.
    # 
    # Example:
    #   class MyPlugin < PluginHost::BaseClass
    #     register_for :my_id
    #     ...
    #   end
    #
    # See PluginHost.register.
    def register_for id
      @plugin_id = id
      plugin_host.register self, id
    end
    
    # Returns the title of the plugin, or sets it to the
    # optional argument +title+.
    def title title = nil
      if title
        @title = title.to_s
      else
        @title ||= name[/([^:]+)$/, 1]
      end
    end
    
    # The PluginHost for this Plugin class.
    def plugin_host host = nil
      if host.is_a? PluginHost
        const_set :PLUGIN_HOST, host
      end
      self::PLUGIN_HOST
    end
    
    def aliases
      plugin_host.plugin_hash.inject [] do |aliases, (key, _)|
        aliases << key if plugin_host[key] == self
        aliases
      end
    end
    
  end
  
end

Version data entries

6,605 entries across 6,596 versions & 60 rubygems

Version Path
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_bank_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_organization_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_id_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_bank_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_organization_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_id_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_id_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_bank_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_organization_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_organization_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_id_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_bank_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
ory-client-1.15.12 vendor/bundle/ruby/3.1.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_bank_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_id_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_organization_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_bank_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_organization_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb
cybrid_api_id_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/coderay-1.1.3/lib/coderay/helpers/plugin.rb