# Class: Concurrent::Actor::Behaviour::Abstract

Inherits:
  Object
  - Object
  - Concurrent::Actor::Behaviour::Abstract
  show all

Includes:
  InternalDelegations, TypeCheck

Defined in:
  lib-edge/concurrent/actor/behaviour/abstract.rb

## Direct Known Subclasses

Awaits, Buffer, ErrorsOnUnknownMessage, ExecutesContext, Linking, Pausing, RemovesChild, SetResults, Supervising, Termination

## Instance Attribute Summary collapse

- #core ⇒ undocumented readonly
- #subsequent ⇒ undocumented readonly

## Instance Method Summary collapse

- #behaviour(behaviour_class) ⇒ undocumented included from InternalDelegations

  see Core#behaviour.

- #behaviour!(behaviour_class) ⇒ undocumented included from InternalDelegations

  see Core#behaviour!.

- #broadcast(public, event) ⇒ undocumented

  broadcasts event to all behaviours and context.

- #Child!(value, *types) ⇒ undocumented included from TypeCheck
- #Child?(value, *types) ⇒ Boolean included from TypeCheck
- #children ⇒ undocumented included from InternalDelegations
- #context ⇒ AbstractContext included from InternalDelegations
- #context_class ⇒ undocumented (also: #actor_class) included from PublicDelegations
- #dead_letter_routing ⇒ undocumented included from InternalDelegations
- #executor ⇒ undocumented included from PublicDelegations
- #initialize(core, subsequent, core_options) ⇒ Abstract constructor

  A new instance of Abstract.

- #log(level, message = nil, &block) ⇒ undocumented included from InternalDelegations

  delegates to core.log.

- #Match!(value, *types) ⇒ undocumented included from TypeCheck
- #Match?(value, *types) ⇒ Boolean included from TypeCheck
- #name ⇒ undocumented included from PublicDelegations
- #on_envelope(envelope) ⇒ undocumented

  override to add extra behaviour.

- #on_event(public, event) ⇒ undocumented

  override to add extra behaviour.

- #parent ⇒ undocumented included from PublicDelegations
- #pass(envelope) ⇒ undocumented
- #path ⇒ undocumented included from PublicDelegations
- #redirect(reference, envelope = self.envelope) ⇒ undocumented included from InternalDelegations
- #reference ⇒ undocumented (also: #ref) included from PublicDelegations
- #reject_envelope(envelope) ⇒ undocumented
- #terminate!(reason = nil) ⇒ undocumented included from InternalDelegations
- #terminated? ⇒ Boolean included from InternalDelegations
- #Type!(value, *types) ⇒ undocumented included from TypeCheck
- #Type?(value, *types) ⇒ Boolean included from TypeCheck

## Constructor Details

### #initialize(core, subsequent, core_options) ⇒ `Abstract`

Returns a new instance of Abstract

    12
    13
    14
    15

    # File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 12

    def initialize(core, subsequent, core_options)
      @core       = Type! core, Core
      @subsequent = Type! subsequent, Abstract, NilClass
    end

## Instance Attribute Details

### #core ⇒ `undocumented` (readonly)

    10
    11
    12

    # File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 10

    def core
      @core
    end

### #subsequent ⇒ `undocumented` (readonly)

    10
    11
    12

    # File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 10

    def subsequent
      @subsequent
    end

## Instance Method Details

### #behaviour(behaviour_class) ⇒ `undocumented` Originally defined in module InternalDelegations

see Core#behaviour

### #behaviour!(behaviour_class) ⇒ `undocumented` Originally defined in module InternalDelegations

see Core#behaviour!

### #broadcast(public, event) ⇒ `undocumented`

broadcasts event to all behaviours and context

See Also:

- #on_event
- AbstractContext#on_event

    37
    38
    39

    # File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 37

    def broadcast(public, event)
      core.broadcast(public, event)
    end

### #Child!(value, *types) ⇒ `undocumented` Originally defined in module TypeCheck

### #Child?(value, *types) ⇒ `Boolean` Originally defined in module TypeCheck

Returns:

- (`Boolean`)

### #children ⇒ `undocumented` Originally defined in module InternalDelegations

See Also:

- Core#children

### #context ⇒ `AbstractContext` Originally defined in module InternalDelegations

Returns:

- (`AbstractContext`)

### #context_class ⇒ `undocumented` Also known as: actor_class Originally defined in module PublicDelegations

See Also:

- Core#context_class

### #dead_letter_routing ⇒ `undocumented` Originally defined in module InternalDelegations

See Also:

- AbstractContext#dead_letter_routing

### #executor ⇒ `undocumented` Originally defined in module PublicDelegations

See Also:

- Core#executor

### #log(level, message = nil, &block) ⇒ `undocumented` Originally defined in module InternalDelegations

delegates to core.log

See Also:

- Logging#log

### #Match!(value, *types) ⇒ `undocumented` Originally defined in module TypeCheck

### #Match?(value, *types) ⇒ `Boolean` Originally defined in module TypeCheck

Returns:

- (`Boolean`)

### #name ⇒ `undocumented` Originally defined in module PublicDelegations

See Also:

- Core#name

### #on_envelope(envelope) ⇒ `undocumented`

Note:

super needs to be called not to break the chain

override to add extra behaviour

    19
    20
    21

    # File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 19

    def on_envelope(envelope)
      pass envelope
    end

### #on_event(public, event) ⇒ `undocumented`

Note:

super needs to be called not to break the chain

override to add extra behaviour

    30
    31
    32

    # File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 30

    def on_event(public, event)
      subsequent.on_event public, event if subsequent
    end

### #parent ⇒ `undocumented` Originally defined in module PublicDelegations

See Also:

- Core#parent

### #pass(envelope) ⇒ `undocumented`

Parameters:

- envelope (`Envelope`) —

  to pass to #subsequent behaviour

    24
    25
    26

    # File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 24

    def pass(envelope)
      subsequent.on_envelope envelope
    end

### #path ⇒ `undocumented` Originally defined in module PublicDelegations

See Also:

- Core#path

### #redirect(reference, envelope = self.envelope) ⇒ `undocumented` Originally defined in module InternalDelegations

### #reference ⇒ `undocumented` Also known as: ref Originally defined in module PublicDelegations

See Also:

- Core#reference

### #reject_envelope(envelope) ⇒ `undocumented`

    41
    42
    43
    44
    45

    # File 'lib-edge/concurrent/actor/behaviour/abstract.rb', line 41

    def reject_envelope(envelope)
      envelope.reject! ActorTerminated.new(reference)
      dead_letter_routing << envelope unless envelope.future
      log(DEBUG) { "rejected #{envelope.message} from #{envelope.sender_path}"}
    end

### #terminate!(reason = nil) ⇒ `undocumented` Originally defined in module InternalDelegations

See Also:

- Termination#terminate!

### #terminated? ⇒ `Boolean` Originally defined in module InternalDelegations

Returns:

- (`Boolean`)

See Also:

- Termination#terminated?

### #Type!(value, *types) ⇒ `undocumented` Originally defined in module TypeCheck

### #Type?(value, *types) ⇒ `Boolean` Originally defined in module TypeCheck

Returns:

- (`Boolean`)