Class: MessageThread

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for(message, user) ⇒ Object



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

def self.for(message, user)
  where(:parent_message_id => (message.parent_id || message.id), :recipient_id => user.id).first
end

Instance Method Details

#creator_nameObject



13
14
15
# File 'app/models/message_thread.rb', line 13

def creator_name
  parent_message.sender.eql?(recipient) ? 'Me' : parent_message.sender.
end

#mark_messages_deletedObject



21
22
23
24
25
26
# File 'app/models/message_thread.rb', line 21

def mark_messages_deleted
  parent_message.mark_deleted(recipient)
  parent_message.children.each do |child|
    child.mark_deleted(recipient)
  end
end

#read?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/models/message_thread.rb', line 28

def read?
  message.recipient.eql?(recipient) ? message.read? : 'read'
end

#subjectObject



9
10
11
# File 'app/models/message_thread.rb', line 9

def subject
  parent_message.subject
end