Module: HubotGf::Worker

Defined in:
lib/hubotgf/worker.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
# File 'lib/hubotgf/worker.rb', line 4

def self.included(base)
  @workers ||= []
  @workers << base
  base.extend(ClassMethods)
end

.start(command, sender = nil, room = nil) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/hubotgf/worker.rb', line 10

def self.start(command, sender = nil, room = nil)
  worker = @workers.find { |w| w.commands.include? command }
  if worker
    command = worker.commands.match(command)
    arguments = command.arguments.unshift(command._method, sender, room)
    HubotGf::Config.perform.(worker, arguments)
  end
end

Instance Method Details

#perform(method, sender, room, *args) ⇒ Object

Sidekiq entry



20
21
22
23
# File 'lib/hubotgf/worker.rb', line 20

def perform(method, sender, room, *args)
  @sender, @room = sender, room
  send method, *args
end

#rebroadcast(message) ⇒ Object



29
30
31
# File 'lib/hubotgf/worker.rb', line 29

def rebroadcast(message)
  HubotGf::Messenger.new.broadcast(@room, message)
end

#reply(message) ⇒ Object



25
26
27
# File 'lib/hubotgf/worker.rb', line 25

def reply(message)
  HubotGf::Messenger.new.pm(@sender, message)
end