diff options
author | Dimid Duchovny <dimidd@gmail.com> | 2018-01-24 23:09:06 +0200 |
---|---|---|
committer | Dimid Duchovny <dimidd@gmail.com> | 2018-01-24 23:09:06 +0200 |
commit | 6a1d06abc6c42e504a83dca4420c1d5ef39f09d2 (patch) | |
tree | 34a5cda26416cd0be617918b179a106baed143f0 | |
parent | aca7c9a93eb77c32ef112c193169a4618d425432 (diff) | |
download | msgthr-6a1d06abc6c42e504a83dca4420c1d5ef39f09d2.tar.gz |
Signed-off-by: Dimid Duchovny <dimidd@gmail.com>
-rw-r--r-- | lib/msgthr.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/msgthr.rb b/lib/msgthr.rb index d88b32b..bf4b14e 100644 --- a/lib/msgthr.rb +++ b/lib/msgthr.rb @@ -148,7 +148,18 @@ class Msgthr # If +mid+ is a String, it is recommended to freeze the string before # calling this method to avoid wasting memory on hash keys. Likewise # is true for any String objects in +refs+. - def add(mid, refs, msg) + # + # Adding a message could link 2 messages in Msgthr, + # by making one message a child of the other. + # It's possible to have a callback called when a child is added + # by passing a block to this method. + # This block can access the child and parent messages. E.g. + # + # msgthr.add(0, nil, '0') + # msgthr.add(1, [0], '1') do |parent, child| + # puts "#{parent.mid} -> #{child.mid}" + # end + def add(mid, refs, msg) # :yields: parent, child @state == :init or raise StateError, "cannot add when already #@state" cur = @id_table[mid] ||= Msgthr::Container.new(mid) |