class Celluloid::Handlers - celluloid-0.16.0 Documentation

# class Celluloid::Handlers

### Public Class Methods

new() click to toggle source

    # File lib/celluloid/handlers.rb, line 5
    def initialize
      @handlers = Set.new
    end

### Public Instance Methods

handle(*patterns, &block) click to toggle source

    # File lib/celluloid/handlers.rb, line 9
    def handle(*patterns, &block)
      patterns.each do |pattern|
        handler = Handler.new pattern, block
        @handlers << handler
      end
    end

handle_message(message) click to toggle source

Handle incoming messages

    # File lib/celluloid/handlers.rb, line 17
    def handle_message(message)
      if handler = @handlers.find { |h| h.match(message) }
        handler.call message
        handler
      end
    end