Module: Mystro::Plugin::Base
- Defined in:
- lib/mystro/plugin.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#command(name, desc, klass = nil, &block) ⇒ Object
def ui(path) name = self.name.split(‘::’).last Mystro::Plugin.register_ui(name, path) end.
- #config_for(klass) ⇒ Object
- #on(event, &block) ⇒ Object
- #register(opts = {}) ⇒ Object
Class Method Details
.included(base) ⇒ Object
93 94 95 |
# File 'lib/mystro/plugin.rb', line 93 def self.included(base) base.extend self end |
Instance Method Details
#command(name, desc, klass = nil, &block) ⇒ Object
def ui(path)
name = self.name.split('::').last
Mystro::Plugin.register_ui(name, path)
end
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/mystro/plugin.rb', line 117 def command(name, desc, klass=nil, &block) on "commands:loaded" do |args| Mystro::Log.debug "loading commands for #{name}" command = args.shift if klass command.subcommand name, "#{desc} (#{self})", klass else command.subcommand name, "#{desc} (#{self})", &block end end end |
#config_for(klass) ⇒ Object
97 98 99 100 101 |
# File 'lib/mystro/plugin.rb', line 97 def config_for(klass) name = klass.name.split('::').last.downcase.to_sym return Mystro.organization.plugins[name] if Mystro.organization.plugins && Mystro.organization.plugins[name] { } end |
#on(event, &block) ⇒ Object
103 104 105 |
# File 'lib/mystro/plugin.rb', line 103 def on(event, &block) Mystro::Plugin.on(self, event, &block) end |
#register(opts = {}) ⇒ Object
107 108 109 110 |
# File 'lib/mystro/plugin.rb', line 107 def register(opts={}) key = self.name.split('::').last.downcase.to_sym Mystro::Plugin.register(key, opts) end |