Class: Datadog::Core::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/core/worker.rb

Overview

Base class for work tasks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Worker

Returns a new instance of Worker.



10
11
12
# File 'lib/datadog/core/worker.rb', line 10

def initialize(&block)
  @task = block
end

Instance Attribute Details

#taskObject

Returns the value of attribute task.



7
8
9
# File 'lib/datadog/core/worker.rb', line 7

def task
  @task
end

Instance Method Details

#perform(*args) ⇒ Object



14
15
16
# File 'lib/datadog/core/worker.rb', line 14

def perform(*args)
  task.call(*args) unless task.nil?
end