Module: Twke::Routes

Defined in:
lib/twke/routes.rb

Defined Under Namespace

Classes: RoutePrefix

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.connObject

Returns the value of attribute conn.



56
57
58
# File 'lib/twke/routes.rb', line 56

def conn
  @conn
end

Class Method Details

.add(trigger, *opts, &blk) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/twke/routes.rb', line 80

def add(trigger, *opts, &blk)
  cmd do
    match(trigger, *opts) do
      # This yields the action (ie, room) context to the
      # callback. All actions that could be done in the Scamp
      # 'match' context can be performed on the yielded
      # object. This lets you pass the context to an EM context
      # later.
      #

      yield(self)
    end
  end
end

.cmd(&blk) ⇒ Object

Run a raw command



96
97
98
# File 'lib/twke/routes.rb', line 96

def cmd(&blk)
  @@conn.behaviour(&blk)
end

.load(scamp) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/twke/routes.rb', line 58

def load(scamp)
  @@conn = scamp

  # TODO: Only load the configured plugins.
  # XXX: doesn't feel right to do this in routes...
  Plugin.plugins.each do |plgin|
    plgin.load_plugin
  end

  # Now ask all loaded plugins to add routes
  Plugin.loaded_plugins.each do |plgin|
    plgin.event(:add_routes, RoutePrefix.new($options[:name]), $options)
  end
end

.on_connectObject

Invoked (in theory) after we’re connected to campfire



74
75
76
77
78
# File 'lib/twke/routes.rb', line 74

def on_connect
  Plugin.loaded_plugins.each do |plgin|
    plgin.event(:on_connect, RoutePrefix.new($options[:name]), $options)
  end
end