lib/sup/thread.rb in sup-0.0.4 vs lib/sup/thread.rb in sup-0.0.5

- old
+ new

@@ -5,11 +5,13 @@ class Thread include Enumerable attr_reader :containers def initialize - raise "wrong thread, buddy!" if block_given? + ## ah, the joys of a multithreaded application with a class called + ## "Thread". i keep instantiating the wrong one... + raise "wrong Thread class, buddy!" if block_given? @containers = [] end def << c @containers << c @@ -26,11 +28,13 @@ puts "=== start thread #{self} with #{@containers.length} trees ===" @containers.each { |c| c.dump_recursive } puts "=== end thread ===" end - ## yields each message and some stuff + ## yields each message, its depth, and its parent + ## note that the message can be a Message object, or :fake_root, + ## or nil. def each fake_root=false adj = 0 root = @containers.find_all { |c| !Message.subj_is_reply?(c) }.argmin { |c| c.date } if root @@ -76,9 +80,10 @@ end def set_labels l; each { |m, *o| m && m.labels = l }; end def has_label? t; any? { |m, *o| m && m.has_label?(t) }; end + def dirty?; any? { |m, *o| m && m.dirty? }; end def save index; each { |m, *o| m && m.save(index) }; end def direct_participants map { |m, *o| [m.from] + m.to if m }.flatten.compact.uniq end