Class: HasMailbox::Models::Message
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- HasMailbox::Models::Message
- Defined in:
- lib/has_mailbox/models/message.rb
Instance Method Summary collapse
- #delete ⇒ Object
- #from ⇒ Object
- #mark_as_read ⇒ Object
- #mark_as_unread ⇒ Object
- #read? ⇒ Boolean
- #to ⇒ Object
- #undelete ⇒ Object
Instance Method Details
#delete ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/has_mailbox/models/message.rb', line 30 def delete unless self.deleted? self.update_attributes!(:deleted => true) else self.destroy end end |
#from ⇒ Object
42 43 44 |
# File 'lib/has_mailbox/models/message.rb', line 42 def from "#{self.}".constantize.find_by_id(self.sender_id) end |
#mark_as_read ⇒ Object
22 23 24 |
# File 'lib/has_mailbox/models/message.rb', line 22 def mark_as_read self.update_attributes!(:opened => true) end |
#mark_as_unread ⇒ Object
26 27 28 |
# File 'lib/has_mailbox/models/message.rb', line 26 def mark_as_unread self.update_attributes!(:opened => false) end |
#read? ⇒ Boolean
18 19 20 |
# File 'lib/has_mailbox/models/message.rb', line 18 def read? self.opened? end |
#to ⇒ Object
46 47 48 |
# File 'lib/has_mailbox/models/message.rb', line 46 def to "#{self.}".constantize.find_by_id(self.) end |
#undelete ⇒ Object
38 39 40 |
# File 'lib/has_mailbox/models/message.rb', line 38 def undelete self.update_attributes!(:deleted => false) end |