Class: Thredded::MessageboardDecorator

Inherits:
SimpleDelegator
  • Object
show all
Includes:
ActionView::Helpers::NumberHelper, ActionView::Helpers::TagHelper
Defined in:
app/decorators/thredded/messageboard_decorator.rb

Instance Method Summary collapse

Constructor Details

#initialize(messageboard) ⇒ MessageboardDecorator

Returns a new instance of MessageboardDecorator.



6
7
8
9
# File 'app/decorators/thredded/messageboard_decorator.rb', line 6

def initialize(messageboard)
  super
  @messageboard = messageboard
end

Instance Method Details

#category_options ⇒ Object



33
34
35
# File 'app/decorators/thredded/messageboard_decorator.rb', line 33

def category_options
  messageboard.categories.map { |cat| [cat.name, cat.id] }
end

#latest_topic ⇒ Object



22
23
24
25
26
27
# File 'app/decorators/thredded/messageboard_decorator.rb', line 22

def latest_topic
  @latest_topic ||= begin
    messageboard.topics.order_latest_first.first ||
      Thredded::NullTopic.new
  end
end

#latest_user ⇒ Object



29
30
31
# File 'app/decorators/thredded/messageboard_decorator.rb', line 29

def latest_user
  latest_topic.last_user
end

#meta ⇒ Object



15
16
17
18
19
20
# File 'app/decorators/thredded/messageboard_decorator.rb', line 15

def meta
  topics_count = number_to_human(messageboard.topics_count)
  posts_count = number_to_human(messageboard.posts_count)

  "#{topics_count} topics / #{posts_count} posts".downcase
end

#original ⇒ Object



11
12
13
# File 'app/decorators/thredded/messageboard_decorator.rb', line 11

def original
  messageboard
end