Reputation: 391
According to the documentation for EventMachine.watch_file the handler
argument has to be a Module (or a class inheriting from EventMachine::FileWatch
). Why is it designed this way? For me a block (or Proc) argument would be more natural and flexible (since it allows to use local variables via closure)...
Upvotes: 1
Views: 32
Reputation: 23949
The docs are not super clear, but you can also supply a sub-class of FileWatch
. That would let you use locals more easily.
It takes either a module with the needed methods, or a class with the needed methods AND it must be a sub-class of the desired class.
Take a look at the code, specifically, the klass_from_handler method.
Upvotes: 1