Sha256: d15115159587effe3dd311570fef946feea0164de84c5dedb33ef0fc20c41a69

Contents?: true

Size: 689 Bytes

Versions: 4

Compression:

Stored size: 689 Bytes

Contents

module MList
  class Thread < ActiveRecord::Base
    set_table_name 'mlist_threads'
    
    belongs_to :mail_list, :class_name => 'MList::MailList', :counter_cache => :threads_count
    has_many :messages, :class_name => 'MList::Message', :dependent => :delete_all
    
    def first?(message)
      messages.first == message
    end
    
    def last?(message)
      messages.last == message
    end
    
    def next(message)
      i = messages.index(message)
      messages[i + 1] unless messages.size < i
    end
    
    def previous(message)
      i = messages.index(message)
      messages[i - 1] if i > 0
    end
    
    def subject
      messages.first.subject
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aiwilliams-mlist-0.1.0 lib/mlist/thread.rb
aiwilliams-mlist-0.1.1 lib/mlist/thread.rb
aiwilliams-mlist-0.1.2 lib/mlist/thread.rb
aiwilliams-mlist-0.1.3 lib/mlist/thread.rb