/usr/lib/ruby/vendor_ruby/celluloid/handlers.rb is in ruby-celluloid 0.16.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | require 'set'
module Celluloid
class Handlers
def initialize
@handlers = Set.new
end
def handle(*patterns, &block)
patterns.each do |pattern|
handler = Handler.new pattern, block
@handlers << handler
end
end
# Handle incoming messages
def handle_message(message)
if handler = @handlers.find { |h| h.match(message) }
handler.call message
handler
end
end
end
# Methods blocking on a call to receive
class Handler
def initialize(pattern, block)
@pattern = pattern
@block = block
end
# Match a message with this receiver's block
def match(message)
@pattern === message
end
def call(message)
@block.call message
end
end
end
|