Class: ActsAsChattable::Message
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActsAsChattable::Message
- Defined in:
- lib/acts_as_chattable/message.rb
Instance Attribute Summary collapse
-
#removed ⇒ Object
Returns the value of attribute removed.
-
#restored ⇒ Object
Returns the value of attribute restored.
Instance Method Summary collapse
- #close ⇒ Object (also: #mark_as_unread, #unread)
- #conversation ⇒ Object
- #delete ⇒ Object
- #open ⇒ Object (also: #mark_as_read, #read)
- #open? ⇒ Boolean
- #participant?(user) ⇒ Boolean
- #people ⇒ Object
- #real_receiver(user) ⇒ Object
- #restore ⇒ Object
Instance Attribute Details
#removed ⇒ Object
Returns the value of attribute removed.
6 7 8 |
# File 'lib/acts_as_chattable/message.rb', line 6 def removed @removed end |
#restored ⇒ Object
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
#close ⇒ Object 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 |
#conversation ⇒ Object
59 60 61 |
# File 'lib/acts_as_chattable/message.rb', line 59 def conversation root.subtree end |
#delete ⇒ Object
63 64 65 |
# File 'lib/acts_as_chattable/message.rb', line 63 def delete self.removed = true end |
#open ⇒ Object 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
32 33 34 |
# File 'lib/acts_as_chattable/message.rb', line 32 def open? self.opened? end |
#participant?(user) ⇒ Boolean
55 56 57 |
# File 'lib/acts_as_chattable/message.rb', line 55 def participant?(user) (to == user) || (from == user) end |
#people ⇒ Object
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 |
#restore ⇒ Object
67 68 69 |
# File 'lib/acts_as_chattable/message.rb', line 67 def restore self.restored = true end |