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

- (Object) removed

Returns the value of attribute removed



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

def removed
  @removed
end

- (Object) restored

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

- (Object) close 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

- (Object) conversation



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

def conversation
  root.subtree
end

- (Object) delete



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

def delete
  self.removed = true
end

- (Object) open 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

- (Boolean) open?



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

def open?
  self.opened?
end

- (Boolean) participant?(user)



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

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

- (Object) people



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

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

- (Object) real_receiver(user)



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

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

- (Object) reply(*args)



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

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

- (Object) restore



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

def restore
  self.restored = true
end