Class: Celluloid::Internals::Links

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

Overview

Linked actors send each other system events

Instance Method Summary collapse

Constructor Details

#initializeLinks

Returns a new instance of Links.



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

def initialize
  @links = {}
end

Instance Method Details

#<<(actor) ⇒ Object

Add an actor to the current links



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

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

#delete(actor) ⇒ Object

Remove an actor from the links



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

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

#eachObject

Iterate through all links



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

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

#include?(actor) ⇒ Boolean

Do links include the given actor?

Returns:

  • (Boolean)


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

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

#inspectObject

Generate a string representation



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

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