Class: Celluloid::LinkingRequest

Inherits:
SystemEvent show all
Defined in:
lib/celluloid/system_events.rb

Overview

Request to link with another actor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actor, type) ⇒ LinkingRequest

Returns a new instance of LinkingRequest.

Raises:

  • (ArgumentError)

9
10
11
12
# File 'lib/celluloid/system_events.rb', line 9

def initialize(actor, type)
  @actor, @type = actor, type.to_sym
  raise ArgumentError, "type must be link or unlink" unless [:link, :unlink].include?(@type)
end

Instance Attribute Details

#actorObject (readonly)

Returns the value of attribute actor


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

def actor
  @actor
end

#typeObject (readonly)

Returns the value of attribute type


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

def type
  @type
end

Instance Method Details

#process(links) ⇒ Object


14
15
16
17
18
19
20
21
# File 'lib/celluloid/system_events.rb', line 14

def process(links)
  case type
  when :link   then links << actor
  when :unlink then links.delete actor
  end

  actor.mailbox << LinkingResponse.new(Actor.current, type)
end