Class: Raktr::Tasks::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/raktr/tasks/base.rb

Overview

Callable task.

Author:

Direct Known Subclasses

OneOff, Persistent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&task) ⇒ Base

Returns a new instance of Base.

Parameters:

  • task (Block)


22
23
24
25
26
# File 'lib/raktr/tasks/base.rb', line 22

def initialize( &task )
    fail ArgumentError, 'Missing block.' if !block_given?

    @task = task
end

Instance Attribute Details

#ownerTasks

Returns List managing this task.

Returns:

  • (Tasks)

    List managing this task.



19
20
21
# File 'lib/raktr/tasks/base.rb', line 19

def owner
  @owner
end

Instance Method Details

#call(*args) ⇒ Object

This method is abstract.

Calls the configured task and passes ‘args` and self` to it.



31
32
33
# File 'lib/raktr/tasks/base.rb', line 31

def call( *args )
    fail NotImplementedError
end

#doneObject

Removes the task from the #owner‘s list.



36
37
38
# File 'lib/raktr/tasks/base.rb', line 36

def done
    @owner.delete self
end

#hashObject



44
45
46
# File 'lib/raktr/tasks/base.rb', line 44

def hash
    @task.hash
end

#to_procObject



40
41
42
# File 'lib/raktr/tasks/base.rb', line 40

def to_proc
    @task
end