Class: Decidim::Debates::DebatePresenter
- Inherits:
-
ResourcePresenter
- Object
- ResourcePresenter
- Decidim::Debates::DebatePresenter
- Includes:
- ActionView::Helpers::DateHelper, ResourceHelper, SanitizeHelper, 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, extras: true, 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
18 19 20 21 22 23 24 25 26 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 18 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
14 15 16 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 14 def debate __getobj__ end |
#description(strip_tags: false, extras: true, links: false, all_locales: false) ⇒ Object
34 35 36 37 38 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 34 def description(strip_tags: false, extras: true, links: false, all_locales: false) return unless debate content_handle_locale(debate.description, all_locales, extras, links, ) end |
#groups_count ⇒ Object
56 57 58 59 60 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 56 def groups_count .count do || .is_a?(Decidim::UserGroup) end end |
#last_comment_at ⇒ Object
40 41 42 43 44 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 40 def last_comment_at return unless debate.last_comment_at time_ago_in_words(debate.last_comment_at) end |
#last_comment_by ⇒ Object
46 47 48 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 46 def last_comment_by debate.last_comment_by&.presenter end |
#participants_count ⇒ Object
50 51 52 53 54 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 50 def participants_count .count do || .is_a?(Decidim::User) end end |
#title(links: false, all_locales: false, html_escape: false) ⇒ Object
28 29 30 31 32 |
# File 'app/presenters/decidim/debates/debate_presenter.rb', line 28 def title(links: false, all_locales: false, html_escape: false) return unless debate super debate.title, links, html_escape, all_locales end |