Class: Message

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#recipientObject

Returns the value of attribute recipient.



17
18
19
# File 'app/models/message.rb', line 17

def recipient
  @recipient
end

Instance Method Details

#readObject



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

Returns:

  • (Boolean)


60
61
62
63
# File 'app/models/message.rb', line 60

def read?
  return true if state == 'read'
  false
end

#send_notificationObject



51
52
53
# File 'app/models/message.rb', line 51

def send_notification
  Notifier.message_notification(id).deliver if receiver.try(:email).present?
end

#set_receiverObject



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