Sha256: c57617d13f04ae2df100126d5e031def2c02f47b619ba739e4b5b902b0e5d792

Contents?: true

Size: 575 Bytes

Versions: 1

Compression:

Stored size: 575 Bytes

Contents

module Aggro
  # Private: Wraps a given target in an concurrent actor.
  class ConcurrentActor < Concurrent::Actor::RestartingContext
    def initialize(target)
      @target = target
    end

    def on_message(message)
      if command? message
        @target.send :apply_command, message
      elsif query? message
        @target.send :run_query, message
      end
    end

    private

    def command?(message)
      message.class.included_modules.include? Command
    end

    def query?(message)
      message.class.included_modules.include? Query
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aggro-0.0.4 lib/aggro/concurrent_actor.rb