Sha256: 29227cae4f569a77a22df28a1ce82ca0e170778efb9b594c3cc5fb60b39ceab5

Contents?: true

Size: 711 Bytes

Versions: 6

Compression:

Stored size: 711 Bytes

Contents

module Pione
  module Agent
    # TrivialRoutineWorker represents agent class for doing action periodly.
    class TrivialRoutineWorker < BasicAgent
      # state
      define_state :working

      # transition table
      define_state_transition :initialized => :working
      define_state_transition :working => :working

      # Create a trivial routine worker.
      #
      # @param action [Proc]
      #   worker's action as proc object
      def initialize(action)
        raise ArgumentError.new(action) unless action.kind_of?(Proc)
        @action = action
      end

      # Call the action.
      #
      # @return [void]
      def transit_to_working
        @action.call
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pione-0.2.2 lib/pione/agent/trivial-routine-worker.rb
pione-0.2.1 lib/pione/agent/trivial-routine-worker.rb
pione-0.2.0 lib/pione/agent/trivial-routine-worker.rb
pione-0.1.4 lib/pione/agent/trivial-routine-worker.rb
pione-0.1.3 lib/pione/agent/trivial-routine-worker.rb
pione-0.1.2 lib/pione/agent/trivial-routine-worker.rb