class Actor::Messaging::Publish::Substitute

Constants

Record

Attributes

records[R]
registered_addresses[R]
unregistered_addresses[R]

Public Class Methods

new() click to toggle source
# File lib/actor/messaging/publish/substitute.rb, line 9
def initialize
  @registered_addresses = Set.new
  @unregistered_addresses = Set.new
  @records = []
end

Public Instance Methods

call(message, wait: nil) click to toggle source
# File lib/actor/messaging/publish/substitute.rb, line 23
def call message, wait: nil
  wait = false if wait.nil?

  record = Record.new message, wait

  records << record
end
published?(message=nil, wait: nil) click to toggle source
# File lib/actor/messaging/publish/substitute.rb, line 47
def published? message=nil, wait: nil
  records.each do |record|
    next unless message.nil? or record.message == message
    next unless wait.nil? or record.wait == wait

    return true
  end

  false
end
register(address) click to toggle source
# File lib/actor/messaging/publish/substitute.rb, line 15
def register address
  registered_addresses << address
end
registered?(address=nil) click to toggle source
# File lib/actor/messaging/publish/substitute.rb, line 31
def registered? address=nil
  if address.nil?
    registered_addresses.any?
  else
    registered_addresses.include? address
  end
end
unregister(address) click to toggle source
# File lib/actor/messaging/publish/substitute.rb, line 19
def unregister address
  unregistered_addresses << address
end
unregistered?(address=nil) click to toggle source
# File lib/actor/messaging/publish/substitute.rb, line 39
def unregistered? address=nil
  if address.nil?
    unregistered_addresses.any?
  else
    unregistered_addresses.include? address
  end
end