Class: Celluloid::Links

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/celluloid/links.rb

Overview

Linked actors send each other system events

Instance Method Summary collapse

Constructor Details

#initializeLinks

Returns a new instance of Links.


6
7
8
# File 'lib/celluloid/links.rb', line 6

def initialize
  @links = {}
end

Instance Method Details

#<<(actor) ⇒ Object

Add an actor to the current links


11
12
13
# File 'lib/celluloid/links.rb', line 11

def <<(actor)
  @links[actor.mailbox.address] = actor
end

#delete(actor) ⇒ Object

Remove an actor from the links


21
22
23
# File 'lib/celluloid/links.rb', line 21

def delete(actor)
  @links.delete actor.mailbox.address
end

#eachObject

Iterate through all links


26
27
28
# File 'lib/celluloid/links.rb', line 26

def each
  @links.each { |_, actor| yield(actor) }
end

#include?(actor) ⇒ Boolean

Do links include the given actor?

Returns:

  • (Boolean)

16
17
18
# File 'lib/celluloid/links.rb', line 16

def include?(actor)
  @links.has_key? actor.mailbox.address
end

#inspectObject

Generate a string representation


31
32
33
34
# File 'lib/celluloid/links.rb', line 31

def inspect
  links = self.map(&:inspect).join(',')
  "#<#{self.class}[#{links}]>"
end