Class: Thredded::BaseTopicView
- Inherits:
-
Object
- Object
- Thredded::BaseTopicView
show all
- Defined in:
- app/view_models/thredded/base_topic_view.rb
Overview
A view model for TopicCommon.
Instance Method Summary
collapse
Constructor Details
#initialize(topic, read_state, policy) ⇒ BaseTopicView
Returns a new instance of BaseTopicView.
21
22
23
24
25
|
# File 'app/view_models/thredded/base_topic_view.rb', line 21
def initialize(topic, read_state, policy)
@read_state = read_state || Thredded::NullUserTopicReadState.new
@topic = topic
@policy = policy
end
|
Instance Method Details
#can_destroy? ⇒ Boolean
35
36
37
|
# File 'app/view_models/thredded/base_topic_view.rb', line 35
def can_destroy?
@policy.destroy?
end
|
#can_update? ⇒ Boolean
31
32
33
|
# File 'app/view_models/thredded/base_topic_view.rb', line 31
def can_update?
@policy.update?
end
|
#path ⇒ Object
39
40
41
|
# File 'app/view_models/thredded/base_topic_view.rb', line 39
def path
Thredded::UrlsHelper.topic_path(@topic, page: @read_state.page)
end
|
#states ⇒ Object
27
28
29
|
# File 'app/view_models/thredded/base_topic_view.rb', line 27
def states
[@read_state.read? ? :read : :unread]
end
|