| Class | Sergi::Acts::Messageable::Mailbox |
| In: |
lib/mailbox.rb
|
| Parent: | Object |
| type | [RW] | this is used to filter mail by mailbox type, use the [] method rather than setting this directly. |
| user | [R] | the user/owner of this mailbox, set when initialized. |
sets the mailbox type and returns itself.
| mailbox_type: | type of mailbox to filter mail by, this can be anything, but the three most likely values for this will be the received, sent, and trash values set within the acts_as_messageable method. |
self
phil = User.find(3123) #all mails in the user's inbox phil.mailbox[:inbox].mail
deletes all messages that have been trashed and match the options if passed.
| options: | see mail for acceptable options. |
returns an array of the latest Mail message for each conversation the user is involved in filtered by type, if set.
*possible use for this would be an inbox view of your mail so you can easily see the status of all the convos your involved in.
| options: | see mail for acceptable options. |
array of Mail.
phil = User.find(3123) #get a list of the latest received mail for each conversation phil.mailbox[:inbox].latest_mail
returns an array of all Mail for the user filtered by type, if set.
| options: | all valid find options are accepted as well as an additional conversation option. |
array of Mail.
phil = User.find(3123) #get all mail messages belonging to phil phil.mailbox.mail #get all mail messages in phil's inbox associated with conversation 23 phil.mailbox[:inbox].mail(:conversation => Conversation.find(23)) #get all unread mail messages belonging to phil associated with conversation 23 phil.mailbox.mail(:conversation => Conversation.find(23), :conditions => 'mail.read = false')
returns a count of mail messages filtered by type and filter, if set.
*this performs an actual sql count rather than selecting all mail and then gettin a length on the array… not a big deal but this could be something that is checked often to notify the user when they receive a new mail.
| filter: | filters the count by the ‘read’ attribute. |
| options: | see mail for acceptable options. |
number of mail messages
phil = User.find(3123) #get number of unread mail messages in phil's inbox phil.mailbox[:inbox].mail_count(:unread)