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(strip_tags: false, links: false, all_locales: false) ⇒ Object
- #groups_count ⇒ Object
- #last_comment_at ⇒ Object
- #last_comment_by ⇒ Object
- #participants_count ⇒ Object
- #title(links: false, all_locales: false, html_escape: false) ⇒ Object
Instance Method Details
#author ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 17 def @author ||= if official? Decidim::Debates::OfficialAuthorPresenter.new elsif user_group Decidim::UserGroupPresenter.new(user_group) 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(strip_tags: false, links: false, all_locales: false) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 33 def description(strip_tags: false, links: false, all_locales: false) return unless debate handle_locales(debate.description, all_locales) do |content| content = (content) if renderer = Decidim::ContentRenderers::HashtagRenderer.new(content) content = renderer.render(links: links).html_safe content = Decidim::ContentRenderers::LinkRenderer.new(content).render if links content end end |
#groups_count ⇒ Object
61 62 63 64 65 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 61 def groups_count .count do || .is_a?(Decidim::UserGroup) end end |
#last_comment_at ⇒ Object
45 46 47 48 49 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 45 def last_comment_at return unless debate.last_comment_at time_ago_in_words(debate.last_comment_at) end |
#last_comment_by ⇒ Object
51 52 53 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 51 def last_comment_by debate.last_comment_by&.presenter end |
#participants_count ⇒ Object
55 56 57 58 59 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 55 def participants_count .count do || .is_a?(Decidim::User) end end |
#title(links: false, all_locales: false, html_escape: false) ⇒ Object
27 28 29 30 31 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 27 def title(links: false, all_locales: false, html_escape: false) return unless debate super debate.title, links, html_escape, all_locales end |