Class: Thredded::MessageboardView

Inherits:
Object
  • Object
show all
Defined in:
app/view_models/thredded/messageboard_view.rb

Overview

A view model for Messageboard.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(messageboard, topics_count: messageboard.topics_count, posts_count: messageboard.posts_count, unread_topics_count: 0, unread_followed_topics_count: 0) ⇒ MessageboardView

Returns a new instance of MessageboardView.

Parameters:

  • messageboard (Thredded::Messageboard)
  • topics_count (Integer) (defaults to: messageboard.topics_count)
  • posts_count (Integer) (defaults to: messageboard.posts_count)
  • unread_topics_count (Integer) (defaults to: 0)
  • unread_followed_topics_count (Integer) (defaults to: 0)

30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/view_models/thredded/messageboard_view.rb', line 30

def initialize(
  messageboard,
  topics_count: messageboard.topics_count,
  posts_count: messageboard.posts_count,
  unread_topics_count: 0,
  unread_followed_topics_count: 0
)
  @messageboard = messageboard
  @topics_count = topics_count
  @posts_count = posts_count
  @unread_topics_count = unread_topics_count
  @unread_followed_topics_count = unread_followed_topics_count
end

Instance Attribute Details

#posts_countInteger (readonly)

Returns:

  • (Integer)

17
18
19
# File 'app/view_models/thredded/messageboard_view.rb', line 17

def posts_count
  @posts_count
end

#topics_countInteger (readonly)

Returns:

  • (Integer)

14
15
16
# File 'app/view_models/thredded/messageboard_view.rb', line 14

def topics_count
  @topics_count
end

#unread_followed_topics_countInteger (readonly)

Returns:

  • (Integer)

23
24
25
# File 'app/view_models/thredded/messageboard_view.rb', line 23

def unread_followed_topics_count
  @unread_followed_topics_count
end

#unread_topics_countInteger (readonly)

Returns:

  • (Integer)

20
21
22
# File 'app/view_models/thredded/messageboard_view.rb', line 20

def unread_topics_count
  @unread_topics_count
end

Instance Method Details

#edit_preferences_pathString

Returns:

  • (String)

60
61
62
# File 'app/view_models/thredded/messageboard_view.rb', line 60

def edit_preferences_path
  Thredded::UrlsHelper.edit_messageboard_preferences_path(@messageboard)
end

#pathString

Returns:

  • (String)

55
56
57
# File 'app/view_models/thredded/messageboard_view.rb', line 55

def path
  Thredded::UrlsHelper.messageboard_topics_path(@messageboard)
end

#unread_followed_topics?Boolean

Returns:

  • (Boolean)

50
51
52
# File 'app/view_models/thredded/messageboard_view.rb', line 50

def unread_followed_topics?
  !@unread_followed_topics_count.zero?
end

#unread_topics?Boolean

Returns:

  • (Boolean)

45
46
47
# File 'app/view_models/thredded/messageboard_view.rb', line 45

def unread_topics?
  !@unread_topics_count.zero?
end