Sha256: d4066ac463751517c4b1d7619b383eb01eba5fd023d56f0b4b337190123befb9

Contents?: true

Size: 744 Bytes

Versions: 1

Compression:

Stored size: 744 Bytes

Contents

# encoding: utf-8
require 'state_machine'

module Punchblock
  class CommandNode < RayoNode

    def initialize(*args)
      super
      @response = FutureResource.new
    end

    state_machine :state, :initial => :new do
      event :request do
        transition :new => :requested
      end

      event :execute do
        transition :requested => :executing
      end

      event :complete do
        transition :executing => :complete
      end
    end

    def response(timeout = nil)
      @response.resource timeout
    end

    def response=(other)
      return if @response.set_yet?
      @response.resource = other
      execute!
    rescue FutureResource::ResourceAlreadySetException
    end
  end # CommandNode
end # Punchblock

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
punchblock-2.3.0 lib/punchblock/command_node.rb