Class: Celluloid::Notifications::Fanout

### Home Classes Methods

### In Files

- lib/celluloid/notifications.rb

### Parent

Object

### Methods

- ::new
- #listeners_for
- #listening?
- #prune
- #publish
- #subscribe
- #unsubscribe

### Included Modules

- Celluloid

### Class/Module Index

Quicksearch

- Celluloid
- Celluloid::Incident
- Celluloid::IncidentLogger
- Celluloid::IncidentLogger::Severity
- Celluloid::IncidentReporter
- Celluloid::IncidentReporter::Formatter
- Celluloid::Internals
- Celluloid::Internals::CPUCounter
- Celluloid::Internals::CallChain
- Celluloid::Internals::Handler
- Celluloid::Internals::Handlers
- Celluloid::Internals::Links
- Celluloid::Internals::Logger
- Celluloid::Internals::Logger::WithBacktrace
- Celluloid::Internals::Method
- Celluloid::Internals::Properties
- Celluloid::Internals::Receiver
- Celluloid::Internals::Receivers
- Celluloid::Internals::Registry
- Celluloid::Internals::Response
- Celluloid::Internals::Response::Block
- Celluloid::Internals::Response::Error
- Celluloid::Internals::Response::Success
- Celluloid::Internals::Signals
- Celluloid::Internals::Stack
- Celluloid::Internals::Stack::ActorState
- Celluloid::Internals::Stack::CellState
- Celluloid::Internals::Stack::DisplayBacktrace
- Celluloid::Internals::Stack::Dump
- Celluloid::Internals::Stack::Summary
- Celluloid::Internals::Stack::TaskState
- Celluloid::Internals::Stack::ThreadState
- Celluloid::Internals::TaskSet
- Celluloid::Internals::ThreadHandle
- Celluloid::Internals::UUID
- Celluloid::LogEvent
- Celluloid::Notifications
- Celluloid::Notifications::Fanout
- Celluloid::Notifications::Subscriber
- Celluloid::Probe
- Celluloid::RingBuffer

No matching classes.

# Celluloid::Notifications::Fanout

### Public Class Methods

new() click to toggle source

    # File lib/celluloid/notifications.rb, line 28
    def initialize
      @subscribers = []
      @listeners_for = {}
    end

### Public Instance Methods

listeners_for(pattern) click to toggle source

    # File lib/celluloid/notifications.rb, line 51
    def listeners_for(pattern)
      @listeners_for[pattern] ||= @subscribers.select { |s| s.subscribed_to?(pattern) }
    end

listening?(pattern) click to toggle source

    # File lib/celluloid/notifications.rb, line 55
    def listening?(pattern)
      listeners_for(pattern).any?
    end

prune(actor, _reason=nil) click to toggle source

    # File lib/celluloid/notifications.rb, line 59
    def prune(actor, _reason=nil)
      @subscribers.reject! { |s| s.actor == actor }
      @listeners_for.clear
    end

publish(pattern, *args) click to toggle source

    # File lib/celluloid/notifications.rb, line 47
    def publish(pattern, *args)
      listeners_for(pattern).each { |s| s.publish(pattern, *args) }
    end

subscribe(actor, pattern, method) click to toggle source

    # File lib/celluloid/notifications.rb, line 33
    def subscribe(actor, pattern, method)
      subscriber = Subscriber.new(actor, pattern, method).tap do |s|
        @subscribers << s
      end
      link actor
      @listeners_for.clear
      subscriber
    end

unsubscribe(subscriber) click to toggle source

    # File lib/celluloid/notifications.rb, line 42
    def unsubscribe(subscriber)
      @subscribers.reject! { |s| s.matches?(subscriber) }
      @listeners_for.clear
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.