Class: Message

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

Instance Method Summary collapse

Instance Method Details

#unread_for?(user) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
# File 'app/models/message.rb', line 18

def unread_for? user
  speaker = self.discussion.find_speaker_by_user(user)
  if speaker
    self.created_at.to_i >= speaker.updated_at.to_i
  else
    true
  end
end

#visible_for?(user) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/models/message.rb', line 14

def visible_for? user
  self.created_at.to_i >= self.discussion.user_invited_at(user).to_i
end