Class: ActsAsMessageable::Message

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Scopes
Defined in:
lib/acts-as-messageable/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#removedObject

Returns the value of attribute removed



10
11
12
# File 'lib/acts-as-messageable/message.rb', line 10

def removed
  @removed
end

#restoredObject

Returns the value of attribute restored



10
11
12
# File 'lib/acts-as-messageable/message.rb', line 10

def restored
  @restored
end

Instance Method Details

#closeObject Also known as: mark_as_unread, unread



25
26
27
# File 'lib/acts-as-messageable/message.rb', line 25

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

#conversationObject



42
43
44
# File 'lib/acts-as-messageable/message.rb', line 42

def conversation
  root.subtree
end

#deleteObject



46
47
48
# File 'lib/acts-as-messageable/message.rb', line 46

def delete
  self.removed = true
end

#openObject Also known as: mark_as_read, read



19
20
21
# File 'lib/acts-as-messageable/message.rb', line 19

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

#open?Boolean



15
16
17
# File 'lib/acts-as-messageable/message.rb', line 15

def open?
  self.opened?
end

#participant?(user) ⇒ Boolean



38
39
40
# File 'lib/acts-as-messageable/message.rb', line 38

def participant?(user)
  user.class.group_messages || (to == user) || (from == user)
end

#peopleObject



58
59
60
# File 'lib/acts-as-messageable/message.rb', line 58

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

#real_receiver(user) ⇒ Object



34
35
36
# File 'lib/acts-as-messageable/message.rb', line 34

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

#reply(*args) ⇒ Object



54
55
56
# File 'lib/acts-as-messageable/message.rb', line 54

def reply(*args)
  to.reply_to(self, *args)
end

#restoreObject



50
51
52
# File 'lib/acts-as-messageable/message.rb', line 50

def restore
  self.restored = true
end