Class: Flor::ModuleGanger

Inherits:
Object
  • Object
show all
Defined in:
lib/flor/unit/gangers.rb

Overview

A ModuleGanger accepts a ‘module:` conf entry that points to a Ruby module. The tasker implementations are searched for among the classes in the given module.

Among the tasker classes (classes that respond to on_task, on_detask, …) it selects the first tasker that matches the tasker name.

Instance Method Summary collapse

Constructor Details

#initialize(service, conf, message) ⇒ ModuleGanger

Returns a new instance of ModuleGanger.



14
15
16
17
18
19
# File 'lib/flor/unit/gangers.rb', line 14

def initialize(service, conf, message)

  @service = service
  @conf = conf
  @message = message
end

Instance Method Details

#taskObject Also known as: detask



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/flor/unit/gangers.rb', line 21

def task

  tas = @message['tasker']
  clas = list_tasker_classes
  cla = clas.find { |c| tasker_name(c) == tas }

  return [ Flor.dup_and_merge(@message, 'routed' => false) ] \
    unless cla

  call_tasker(cla)
end