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.
Class Method Summary collapse
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 |
Class Method Details
.per_page ⇒ Object
43 44 45 |
# File 'app/models/message.rb', line 43 def self.per_page 10 end |
Instance Method Details
#read ⇒ Object
57 58 59 60 |
# File 'app/models/message.rb', line 57 def read self.read_at = Time.zone.now unless self.read_at self.save(:validate => false) end |
#read? ⇒ Boolean
62 63 64 65 |
# File 'app/models/message.rb', line 62 def read? return true if state == 'read' false end |
#send_notification ⇒ Object
53 54 55 |
# File 'app/models/message.rb', line 53 def send_notification Notifier.delay.(self) if receiver.try(:email).present? end |
#set_receiver ⇒ Object
47 48 49 50 51 |
# File 'app/models/message.rb', line 47 def set_receiver if self.recipient self.receiver = User.find(self.recipient) end end |