Class: Observed::MutableTask

Inherits:
Object
  • Object
show all
Defined in:
lib/observed/task.rb

Instance Method Summary collapse

Constructor Details

#initialize(current_task) ⇒ MutableTask

Returns a new instance of MutableTask.



27
28
29
30
# File 'lib/observed/task.rb', line 27

def initialize(current_task)
  @current_task = current_task
  @mutex = Mutex.new
end

Instance Method Details

#now(data = {}, options = nil) ⇒ Object



31
32
33
34
35
# File 'lib/observed/task.rb', line 31

def now(data={}, options=nil)
  @current_task.now(data, options) do |data, options2|
    yield data, (options2 || options) if block_given?
  end
end

#then(*tasks) ⇒ Object



36
37
38
39
40
41
# File 'lib/observed/task.rb', line 36

def then(*tasks)
  @mutex.synchronize do
    @current_task = @current_task.then(*tasks)
  end
  self
end