Class: ActsAsChattable::Message

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/acts_as_chattable/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#removedObject

Returns the value of attribute removed.



6
7
8
# File 'lib/acts_as_chattable/message.rb', line 6

def removed
  @removed
end

#restoredObject

Returns the value of attribute restored.



6
7
8
# File 'lib/acts_as_chattable/message.rb', line 6

def restored
  @restored
end

Instance Method Details

#closeObject Also known as: mark_as_unread, unread



42
43
44
# File 'lib/acts_as_chattable/message.rb', line 42

def close
  update_attributes!(:opened => false)
end

#conversationObject



59
60
61
# File 'lib/acts_as_chattable/message.rb', line 59

def conversation
  root.subtree
end

#deleteObject



63
64
65
# File 'lib/acts_as_chattable/message.rb', line 63

def delete
  self.removed = true
end

#openObject Also known as: mark_as_read, read



36
37
38
# File 'lib/acts_as_chattable/message.rb', line 36

def open
  update_attributes!(:opened => true)
end

#open?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/acts_as_chattable/message.rb', line 32

def open?
  self.opened?
end

#participant?(user) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/acts_as_chattable/message.rb', line 55

def participant?(user)
  (to == user) || (from == user)
end

#peopleObject



71
72
73
# File 'lib/acts_as_chattable/message.rb', line 71

def people
  conversation.map{ |x| x.from }.uniq!
end

#real_receiver(user) ⇒ Object



51
52
53
# File 'lib/acts_as_chattable/message.rb', line 51

def real_receiver(user)
  user == from ? to : from
end

#restoreObject



67
68
69
# File 'lib/acts_as_chattable/message.rb', line 67

def restore
  self.restored = true
end