Sha256: 89f1618184a383636e5a8400ed1d8a0b8c9ac730d5e0f32dc4313f9e8f98923a

Contents?: true

Size: 563 Bytes

Versions: 3

Compression:

Stored size: 563 Bytes

Contents

module Proletariat
  # Internal: Common behavior for actor base classes.
  module ActorCommon
    def self.included(base)
      base.class_exec do
        def initialize(*args)
          starting if respond_to?(:starting)

          super

          started if respond_to?(:started)
        end
      end
    end

    def on_event(event)
      if event == :terminated
        stopping if respond_to?(:stopping)

        cleanup if respond_to?(:cleanup)

        super

        stopped if respond_to?(:stopped)
      else
        super
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
proletariat-0.1.2 lib/proletariat/concurrency/actor_common.rb
proletariat-0.1.1 lib/proletariat/concurrency/actor_common.rb
proletariat-0.1.0 lib/proletariat/concurrency/actor_common.rb