Class: Message

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

Instance Attribute Summary collapse

Class Method 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

Class Method Details

.per_pageObject



43
44
45
# File 'app/models/message.rb', line 43

def self.per_page
  10
end

Instance Method Details

#readObject



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

Returns:

  • (Boolean)


62
63
64
65
# File 'app/models/message.rb', line 62

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

#send_notificationObject



53
54
55
# File 'app/models/message.rb', line 53

def send_notification
  Notifier.delay.message_notification(self) if receiver.try(:email).present?
end

#set_receiverObject



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