Class: Actor::Messaging::Send::Substitute

Inherits:
Object
  • Object
show all
Defined in:
lib/actor/messaging/send/substitute.rb

Defined Under Namespace

Classes: Record

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSubstitute

Returns a new instance of Substitute.



7
8
9
# File 'lib/actor/messaging/send/substitute.rb', line 7

def initialize
  @records = []
end

Instance Attribute Details

#recordsObject (readonly)

Returns the value of attribute records.



5
6
7
# File 'lib/actor/messaging/send/substitute.rb', line 5

def records
  @records
end

Instance Method Details

#call(message, address, wait: nil) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/actor/messaging/send/substitute.rb', line 11

def call message, address, wait: nil
  wait = false if wait.nil?

  record = Record.new message, address, wait

  records << record
end

#sent?(message = nil, address: nil, wait: nil) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
29
# File 'lib/actor/messaging/send/substitute.rb', line 19

def sent? message=nil, address: nil, wait: nil
  records.each do |record|
    next unless message.nil? or record.message? message
    next unless address.nil? or record.address == address
    next unless wait.nil? or record.wait == wait

    return true
  end

  false
end