Module: HasMailbox::Models::InstanceMethods
- Defined in:
- lib/has_mailbox/has_mailbox.rb
Instance Method Summary collapse
-
#empty_mailbox(options = {}) ⇒ Object
to delete empty all of the messages inbox message will be move as a trash message, outgoing messages / outbox will be deleted forever and trash messages also will be deleted forever from the tables.
- #has_unread_messages? ⇒ Boolean
-
#inbox ⇒ Object
retrieve all receiving messages.
-
#outbox ⇒ Object
retrieve all sent/outgoing messages.
- #send_message(subject, body, *recipients) ⇒ Object
-
#send_message?(subject, body, *recipients) ⇒ Boolean
send message instance method.
-
#trash ⇒ Object
retrieve all messages that being deleted (still in the trash but not yet destroyed).
Instance Method Details
#empty_mailbox(options = {}) ⇒ Object
to delete empty all of the messages
inbox message will be move as a trash message, outgoing messages / outbox will be deleted forever and trash messages also will be deleted forever from the tables.
-
:options => :inbox, :outbox, :trash
-
USAGE pass the parameter as boolean value
-
i.e : @user_obj.empty_mailbox(:trash => true)
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/has_mailbox/has_mailbox.rb', line 67 def empty_mailbox( = {}) if .empty? self..delete_all self..delete_all elsif [:inbox] self.inbox.update_all(:deleted => true) elsif [:outbox] self.outbox.delete_all elsif [:trash] self.trash.delete_all end end |
#has_unread_messages? ⇒ Boolean
24 25 26 |
# File 'lib/has_mailbox/has_mailbox.rb', line 24 def inbox.exists?(:opened => false) end |
#inbox ⇒ Object
retrieve all receiving messages
51 52 53 |
# File 'lib/has_mailbox/has_mailbox.rb', line 51 def inbox self..where(:deleted => false) end |
#outbox ⇒ Object
retrieve all sent/outgoing messages
46 47 48 |
# File 'lib/has_mailbox/has_mailbox.rb', line 46 def outbox self. end |
#send_message(subject, body, *recipients) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/has_mailbox/has_mailbox.rb', line 38 def (subject, body, *recipients) recipients.each do |rec| (subject, body, rec) (subject, body, rec) end end |
#send_message?(subject, body, *recipients) ⇒ Boolean
send message instance method
29 30 31 32 33 34 35 36 |
# File 'lib/has_mailbox/has_mailbox.rb', line 29 def (subject, body, *recipients) begin (subject, body, *recipients) true rescue Exception => e false end end |
#trash ⇒ Object
retrieve all messages that being deleted (still in the trash but not yet destroyed)
56 57 58 |
# File 'lib/has_mailbox/has_mailbox.rb', line 56 def trash self..where(:deleted => true) end |