Class: Decidim::Debates::DebatePresenter
- Inherits:
-
ResourcePresenter
- Object
- ResourcePresenter
- Decidim::Debates::DebatePresenter
- Includes:
- ActionView::Helpers::DateHelper, ResourceHelper, TranslationsHelper
- Defined in:
- app/presenters/decidim/debates/debate_presenter.rb
Overview
Decorator for debates
Instance Method Summary collapse
- #author ⇒ Object
- #debate ⇒ Object
- #description(links: false, strip_tags: false, all_locales: false) ⇒ Object
- #last_comment_at ⇒ Object
- #last_comment_by ⇒ Object
- #participants_count ⇒ Object
- #title(html_escape: false, all_locales: false) ⇒ Object
Instance Method Details
#author ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 17 def @author ||= if official? Decidim::Debates::OfficialAuthorPresenter.new else Decidim::UserPresenter.new(super) end end |
#debate ⇒ Object
13 14 15 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 13 def debate __getobj__ end |
#description(links: false, strip_tags: false, all_locales: false) ⇒ Object
31 32 33 34 35 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 31 def description(links: false, strip_tags: false, all_locales: false) return unless debate content_handle_locale(debate.description, all_locales, links, ) end |
#last_comment_at ⇒ Object
37 38 39 40 41 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 37 def last_comment_at return unless debate.last_comment_at time_ago_in_words(debate.last_comment_at) end |
#last_comment_by ⇒ Object
43 44 45 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 43 def last_comment_by debate.last_comment_by&.presenter end |
#participants_count ⇒ Object
47 48 49 50 51 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 47 def participants_count .count do || .is_a?(Decidim::User) && !.group? end end |
#title(html_escape: false, all_locales: false) ⇒ Object
25 26 27 28 29 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 25 def title(html_escape: false, all_locales: false) return unless debate super(debate.title, html_escape, all_locales) end |