class Delayer::Deferred::Chain::Await

Public Class Methods

new(worker:, deferred:) click to toggle source
Calls superclass method
# File lib/delayer/deferred/chain/await.rb, line 5
def initialize(worker:, deferred:)
  super()
  @worker, @awaiting_deferred = worker, deferred
  deferred.add_awaited(self)
end

Public Instance Methods

activate(response) click to toggle source
# File lib/delayer/deferred/chain/await.rb, line 11
def activate(response)
  change_sequence(:activate)
  @worker.give_response(response, @awaiting_deferred)
# TODO: 即座にspoilさせてよさそう
ensure
  change_sequence(:complete)
end
graph_child(output:) click to toggle source
# File lib/delayer/deferred/chain/await.rb, line 19
def graph_child(output:)
  output << graph_mynode
  if has_child?
    @child.graph_child(output: output)
    @awaiting_deferred.graph_child(output: output)
    output << "#{__id__} -> #{@child.__id__}"
  end
  nil
end
graph_mynode() click to toggle source
# File lib/delayer/deferred/chain/await.rb, line 37
def graph_mynode
  label = "#{node_name}\n(#{sequence.name})"
  "#{__id__} [shape=#{graph_shape},label=#{label.inspect}]"
end
graph_shape() click to toggle source
# File lib/delayer/deferred/chain/await.rb, line 33
def graph_shape
  'circle'.freeze
end
node_name() click to toggle source
# File lib/delayer/deferred/chain/await.rb, line 29
def node_name
  "Await"
end