Class: Message
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Message
- Defined in:
- app/models/message.rb
Instance Attribute Summary collapse
-
#recipient ⇒ Object
Returns the value of attribute recipient.
Instance Method Summary collapse
Instance Attribute Details
#recipient ⇒ Object
Returns the value of attribute recipient.
17 18 19 |
# File 'app/models/message.rb', line 17 def recipient @recipient end |
Instance Method Details
#read ⇒ Object
55 56 57 58 |
# File 'app/models/message.rb', line 55 def read self.read_at = Time.zone.now unless self.read_at self.save(:validate => false) end |
#read? ⇒ Boolean
60 61 62 63 |
# File 'app/models/message.rb', line 60 def read? return true if state == 'read' false end |
#send_notification ⇒ Object
51 52 53 |
# File 'app/models/message.rb', line 51 def send_notification Notifier.(id).deliver if receiver.try(:email).present? end |
#set_receiver ⇒ Object
45 46 47 48 49 |
# File 'app/models/message.rb', line 45 def set_receiver if self.recipient self.receiver = User.find(self.recipient) end end |