Class: Thredded::PrivateTopic
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Thredded::PrivateTopic
show all
- Extended by:
- FriendlyId
- Includes:
- TopicCommon
- Defined in:
- app/models/thredded/private_topic.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#last_user, #private?, #user
Class Method Details
.find_by_slug(slug) ⇒ Object
15
16
17
18
19
|
# File 'app/models/thredded/private_topic.rb', line 15
def self.find_by_slug(slug)
friendly.find(slug)
rescue ActiveRecord::RecordNotFound
raise Thredded::Errors::PrivateTopicNotFound
end
|
.for_user(user) ⇒ Object
33
34
35
36
|
# File 'app/models/thredded/private_topic.rb', line 33
def self.for_user(user)
joins(:private_users)
.where(thredded_private_users: { user_id: user.id })
end
|
Instance Method Details
#add_user(user) ⇒ Object
38
39
40
41
42
43
44
|
# File 'app/models/thredded/private_topic.rb', line 38
def add_user(user)
if String == user.class
user = Thredded.user_class.find_by_name(user)
end
users << user
end
|
#categories ⇒ Object
29
30
31
|
# File 'app/models/thredded/private_topic.rb', line 29
def categories
[]
end
|
#decorate ⇒ Object
21
22
23
|
# File 'app/models/thredded/private_topic.rb', line 21
def decorate
TopicDecorator.new(self)
end
|
#public? ⇒ Boolean
46
47
48
|
# File 'app/models/thredded/private_topic.rb', line 46
def public?
false
end
|
#user_id=(ids) ⇒ Object
50
51
52
53
54
|
# File 'app/models/thredded/private_topic.rb', line 50
def user_id=(ids)
return unless ids.size > 0
self.users = Thredded.user_class.where(id: ids.uniq)
end
|
#user_topic_reads ⇒ Object
25
26
27
|
# File 'app/models/thredded/private_topic.rb', line 25
def user_topic_reads
[]
end
|
#users_to_sentence ⇒ Object
56
57
58
|
# File 'app/models/thredded/private_topic.rb', line 56
def users_to_sentence
users.map { |user| user.to_s.capitalize }.to_sentence
end
|