Class: Celluloid::Internals::Handlers
- Inherits:
-
Object
- Object
- Celluloid::Internals::Handlers
- Defined in:
- lib/celluloid/internals/handlers.rb
Instance Method Summary collapse
- #handle(*patterns, &block) ⇒ Object
-
#handle_message(message) ⇒ Object
Handle incoming messages.
-
#initialize ⇒ Handlers
constructor
A new instance of Handlers.
Constructor Details
#initialize ⇒ Handlers
Returns a new instance of Handlers.
6 7 8 |
# File 'lib/celluloid/internals/handlers.rb', line 6 def initialize @handlers = Set.new end |
Instance Method Details
#handle(*patterns, &block) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/celluloid/internals/handlers.rb', line 10 def handle(*patterns, &block) patterns.each do |pattern| handler = Handler.new pattern, block @handlers << handler end end |
#handle_message(message) ⇒ Object
Handle incoming messages
18 19 20 21 22 |
# File 'lib/celluloid/internals/handlers.rb', line 18 def () handler = @handlers.find { |h| h.match() } handler.call if handler handler end |