Class: HasMailbox::Models::Message

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/has_mailbox/models/message.rb

Instance Method Summary collapse

Instance Method Details

#deleteObject



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

#fromObject



42
43
44
# File 'lib/has_mailbox/models/message.rb', line 42

def from
	"#{self.received_messageable_type}".constantize.find_by_id(self.sender_id)
end

#mark_as_readObject



22
23
24
# File 'lib/has_mailbox/models/message.rb', line 22

def mark_as_read
  self.update_attributes!(:opened => true) 
end

#mark_as_unreadObject



26
27
28
# File 'lib/has_mailbox/models/message.rb', line 26

def mark_as_unread
  self.update_attributes!(:opened => false)
end

#read?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/has_mailbox/models/message.rb', line 18

def read?
  self.opened?
end

#toObject



46
47
48
# File 'lib/has_mailbox/models/message.rb', line 46

def to
	"#{self.received_messageable_type}".constantize.find_by_id(self.received_messageable_id)
end

#undeleteObject



38
39
40
# File 'lib/has_mailbox/models/message.rb', line 38

def undelete
  self.update_attributes!(:deleted => false)
end