Sha256: 5121d61a35eecfa748ac5ec0f81a33b3f8e4cb7339c1186daf7013cf7fecc1b7
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
class Mailbox attr_accessor :type attr_reader :messageable def initialize(recipient, box = :all) @messageable = recipient end def conversations(options = {}) conv = Conversation.participant(@messageable) if options[:mailbox_type].present? case options[:mailbox_type] when 'inbox' conv = Conversation.inbox(@messageable) when 'sentbox' conv = Conversation.sentbox(@messageable) when 'trash' conv = Conversation.trash(@messageable) end end if (options[:read].present? and options[:read]==false) or (options[:unread].present? and options[:unread]==true) conv = conv.unread(@messageable) end return conv.uniq end def inbox(options={}) options = options.merge(:mailbox_type => 'inbox') return self.conversations(options) end def sentbox(options={}) options = options.merge(:mailbox_type => 'sentbox') return self.conversations(options) end def trash(options={}) options = options.merge(:mailbox_type => 'trash') return self.conversations(options) end def receipts(options = {}) return Receipt.where(options).receiver(@messageable) end def empty_trash(options = {}) return false end def has_conversation?(conversation) return conversation.is_participant?(@messageable) end def is_trashed?(conversation) return conversation.is_trashed?(@messageable) end def is_completely_trashed?(conversation) return conversation.is_completely_trashed?(@messageable) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mailboxer-0.0.14 | app/models/mailbox.rb |