Class: Celluloid::Internals::Links
- Inherits:
-
Object
- Object
- Celluloid::Internals::Links
- Includes:
- Enumerable
- Defined in:
- lib/celluloid/internals/links.rb
Overview
Linked actors send each other system events
Instance Method Summary collapse
-
#<<(actor) ⇒ Object
Add an actor to the current links.
-
#delete(actor) ⇒ Object
Remove an actor from the links.
-
#each ⇒ Object
Iterate through all links.
-
#include?(actor) ⇒ Boolean
Do links include the given actor?.
-
#initialize ⇒ Links
constructor
A new instance of Links.
-
#inspect ⇒ Object
Generate a string representation.
Constructor Details
#initialize ⇒ Links
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 |
#each ⇒ Object
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?
17 18 19 |
# File 'lib/celluloid/internals/links.rb', line 17 def include?(actor) @links.key? actor.mailbox.address end |
#inspect ⇒ Object
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 |