Class: Concurrent::Actor::Behaviour::Abstract
- Inherits:
-
Object
- Object
- Concurrent::Actor::Behaviour::Abstract
- Includes:
- InternalDelegations, TypeCheck
- Defined in:
- lib/concurrent/actor/behaviour/abstract.rb
Direct Known Subclasses
Awaits, Buffer, ErrorsOnUnknownMessage, ExecutesContext, Linking, Pausing, RemovesChild, SetResults, Supervised, Supervising, TerminatesChildren, Termination
Instance Attribute Summary collapse
-
#core ⇒ Object
readonly
Returns the value of attribute core.
-
#subsequent ⇒ Object
readonly
Returns the value of attribute subsequent.
Instance Method Summary collapse
-
#broadcast(event) ⇒ Object
broadcasts event to all behaviours and context.
-
#initialize(core, subsequent) ⇒ Abstract
constructor
A new instance of Abstract.
-
#on_envelope(envelope) ⇒ Object
override to add extra behaviour.
-
#on_event(event) ⇒ Object
override to add extra behaviour.
- #pass(envelope) ⇒ Object
- #reject_envelope(envelope) ⇒ Object
Methods included from InternalDelegations
#behaviour, #behaviour!, #children, #context, #dead_letter_routing, #log, #redirect, #terminate!
Methods included from PublicDelegations
#context_class, #executor, #name, #parent, #path, #reference
Methods included from TypeCheck
#Child!, #Child?, #Match!, #Match?, #Type!, #Type?
Constructor Details
#initialize(core, subsequent) ⇒ Abstract
Returns a new instance of Abstract.
10 11 12 13 |
# File 'lib/concurrent/actor/behaviour/abstract.rb', line 10 def initialize(core, subsequent) @core = Type! core, Core @subsequent = Type! subsequent, Abstract, NilClass end |
Instance Attribute Details
#core ⇒ Object (readonly)
Returns the value of attribute core.
8 9 10 |
# File 'lib/concurrent/actor/behaviour/abstract.rb', line 8 def core @core end |
#subsequent ⇒ Object (readonly)
Returns the value of attribute subsequent.
8 9 10 |
# File 'lib/concurrent/actor/behaviour/abstract.rb', line 8 def subsequent @subsequent end |
Instance Method Details
#broadcast(event) ⇒ Object
broadcasts event to all behaviours and context
35 36 37 |
# File 'lib/concurrent/actor/behaviour/abstract.rb', line 35 def broadcast(event) core.broadcast(event) end |
#on_envelope(envelope) ⇒ Object
super needs to be called not to break the chain
override to add extra behaviour
17 18 19 |
# File 'lib/concurrent/actor/behaviour/abstract.rb', line 17 def on_envelope(envelope) pass envelope end |
#on_event(event) ⇒ Object
super needs to be called not to break the chain
override to add extra behaviour
28 29 30 |
# File 'lib/concurrent/actor/behaviour/abstract.rb', line 28 def on_event(event) subsequent.on_event event if subsequent end |
#pass(envelope) ⇒ Object
22 23 24 |
# File 'lib/concurrent/actor/behaviour/abstract.rb', line 22 def pass(envelope) subsequent.on_envelope envelope end |
#reject_envelope(envelope) ⇒ Object
39 40 41 42 43 |
# File 'lib/concurrent/actor/behaviour/abstract.rb', line 39 def reject_envelope(envelope) envelope.reject! ActorTerminated.new(reference) dead_letter_routing << envelope unless envelope.ivar log Logging::DEBUG, "rejected #{envelope.message} from #{envelope.sender_path}" end |