Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] [PATCH] Add an after-add-message hook
@ 2009-08-16 21:47 Kevin Riggle
  2009-08-18 17:56 ` William Morgan
  0 siblings, 1 reply; 8+ messages in thread
From: Kevin Riggle @ 2009-08-16 21:47 UTC (permalink / raw)


From: Kevin Riggle <kevinr at black-opal.mit.edu>

I want to do some unrelated processing on each message I receive, but I
don't want to block the message being added to the index.  This patch
adds a hook which runs /after/ the message is added to the index.
---
 lib/sup/poll.rb |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
index 8a9d218..e4b7e02 100644
--- a/lib/sup/poll.rb
+++ b/lib/sup/poll.rb
@@ -11,6 +11,12 @@ Variables:
   message: the new message
 EOS
 
+  HookManager.register "after-add-message", <<EOS
+Executes after a message is added to the index.
+Variables:
+  message: the new message
+EOS
+
   HookManager.register "before-poll", <<EOS
 Executes immediately before a poll for new messages commences.
 No variables.
@@ -156,6 +162,7 @@ EOS
         m_ret = yield(m_old, m_new, offset) or next if block_given?
         Index.sync_message m_ret, opts
         UpdateManager.relay self, :added, m_ret unless m_old
+        HookManager.run "after-add-message", :message => m_new
       end
     rescue SourceError => e
       Redwood::log "problem getting messages from #{source}: #{e.message}"
-- 
1.6.0.4



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-09-02 13:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-16 21:47 [sup-talk] [PATCH] Add an after-add-message hook Kevin Riggle
2009-08-18 17:56 ` William Morgan
2009-08-18 23:36   ` Kevin Riggle
2009-08-19 18:55     ` William Morgan
2009-08-21  1:57       ` Kevin Riggle
2009-08-24 22:44         ` William Morgan
2009-09-02 13:53           ` William Morgan
2009-08-21  2:07       ` Kevin Riggle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox