Class: Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/twke/plugin.rb

Class Method Summary collapse

Class Method Details

.inherited(plgn) ⇒ Object

Registers the current plugin with the system.

Returns nothing.



35
36
37
38
39
# File 'lib/twke/plugin.rb', line 35

def inherited(plgn)
  Plugin.plugins << plgn
  Twke.plugin(plgn)
  super
end

.plugin_nameObject

Returns a short name for the plugin



6
7
8
9
10
11
12
13
# File 'lib/twke/plugin.rb', line 6

def plugin_name
  @plugin_name ||= begin
    str = name.dup
    str.downcase!
    str.sub! /.*:/, ''
    str
  end
end

.pluginsObject

Track all the available plugins



17
18
19
# File 'lib/twke/plugin.rb', line 17

def plugins
  @plugins ||= []
end

.routes(rp) ⇒ Object

Invoked when adding routes. Pass in params here. Could expand this to receive a number of events.



24
25
26
27
28
29
30
# File 'lib/twke/plugin.rb', line 24

def routes(rp)
  plgin = new()

  if plgin.respond_to?(:add_routes)
    plgin.add_routes(rp)
  end
end