Method: Cinch::Test#catch_direct_messages

Defined in:
lib/cinch/test.rb

#catch_direct_messages(message, mutex, replies) ⇒ Object



103
104
105
106
107
108
109
110
111
112
# File 'lib/cinch/test.rb', line 103

def catch_direct_messages(message, mutex, replies)
  (class << message.user; self; end).class_eval do
    [:send, :msg, :privmsg].each do |method|
      define_method method do |msg, notice = false|
        reply = Reply.new(msg, (notice ? :notice : :private), Time.now)
        mutex.synchronize { replies << reply }
      end
    end
  end
end