Module: Rig::Plugin::Base

Defined in:
lib/rig/plugin.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



37
38
39
# File 'lib/rig/plugin.rb', line 37

def self.included(base)
  base.extend self
end

Instance Method Details

#command(name, desc, klass = nil, &block) ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/rig/plugin.rb', line 45

def command(name, desc, klass=nil, &block)
  on "commands:loaded" do |args|
    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



56
57
58
59
60
61
# File 'lib/rig/plugin.rb', line 56

def config_for(klass)
  name = klass.name.split('::').last.downcase.to_sym
  return Rig.config[:plugins][name] if Rig.config[:plugins] && Rig.config[:plugins][name]
  return Rig.[:plugins][name] if Rig.[:plugins] && Rig.[:plugins][name]
  { }
end

#on(event, &block) ⇒ Object



41
42
43
# File 'lib/rig/plugin.rb', line 41

def on(event, &block)
  Rig::Plugin.on(self, event, &block)
end