Class: Discuss::Conversation

Inherits:
Object
  • Object
show all
Defined in:
app/models/discuss/conversation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, user = nil) ⇒ Conversation

Returns a new instance of Conversation.


8
9
10
11
# File 'app/models/discuss/conversation.rb', line 8

def initialize(message, user=nil)
  @message = message
  @user = user || message.user
end

Instance Attribute Details

#messageObject

Returns the value of attribute message


6
7
8
# File 'app/models/discuss/conversation.rb', line 6

def message
  @message
end

#userObject

Returns the value of attribute user


6
7
8
# File 'app/models/discuss/conversation.rb', line 6

def user
  @user
end

Instance Method Details

#allObject


21
22
23
# File 'app/models/discuss/conversation.rb', line 21

def all
  root.subtree
end

#for_userObject


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

def for_user
  all.by_user(user)
end

#rootObject


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

def root
  message.root
end

#trash_conversation!Object


25
26
27
# File 'app/models/discuss/conversation.rb', line 25

def trash_conversation!
  for_user.each { |message| message.trash! }
end