about summary refs log tree commit homepage
path: root/lib/msgthr.rb
diff options
context:
space:
mode:
authorDimid Duchovny <dimidd@gmail.com>2018-01-23 22:34:22 +0200
committerDimid Duchovny <dimidd@gmail.com>2018-01-23 22:34:22 +0200
commit1c701717d10879d492d8b55fb8ca2f1c53d7e13f (patch)
tree3d79d935e11c880174473583c14438bd4cd09785 /lib/msgthr.rb
parentc7e0972eb81e53ddbe1def3d6d8439dcb6b907e4 (diff)
downloadmsgthr-1c701717d10879d492d8b55fb8ca2f1c53d7e13f.tar.gz
The motivation is to allow the client to have a custom code executed,
    whenever a child is added.

    Signed-off-by: Dimid Duchovny <dimidd@gmail.com>
Diffstat (limited to 'lib/msgthr.rb')
-rw-r--r--lib/msgthr.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/msgthr.rb b/lib/msgthr.rb
index 1517f28..d88b32b 100644
--- a/lib/msgthr.rb
+++ b/lib/msgthr.rb
@@ -166,12 +166,16 @@ class Msgthr
       # but do not change existing links or loop
       if prev && !cont.parent && !cont.has_descendent(prev)
         prev.add_child(cont)
+        yield(prev, cont) if block_given?
       end
       prev = cont
     end
 
     # set parent of this message to be the last element in refs
-    prev.add_child(cur) if prev
+    if prev
+      prev.add_child(cur)
+      yield(prev, cur) if block_given?
+    end
   end
 end