module DccImageHooks
DccImageHooks — pub/sub after DCC image registration. Public: on_image, dispatch, clear_handlers! Depends: (none) Tests: test/lib/dcc_image_hooks_test.rb
Public Instance Methods
Source
# File lib/dcc_image_hooks.rb, line 27 def clear_handlers! @mutex.synchronize { @handlers.clear } end
Source
# File lib/dcc_image_hooks.rb, line 18 def dispatch(network:, nick:, entry:) handlers = @mutex.synchronize { @handlers.dup } handlers.each do |handler| handler.call(network: network, nick: nick, entry: entry) rescue StandardError => e warn "[rabbot] dcc_image_hooks handler failed: #{e.class}: #{e.message}" end end
Source
# File lib/dcc_image_hooks.rb, line 14 def on_image(&block) @mutex.synchronize { @handlers << block } end