Class: Decidim::HashtagPresenter

Inherits:
SimpleDelegator
  • Object
show all
Includes:
ActionView::Helpers::UrlHelper
Defined in:
decidim-core/app/presenters/decidim/hashtag_presenter.rb

Overview

Decorator for users

Instance Method Summary collapse

Constructor Details

#initialize(hashtag, cased_name: nil) ⇒ HashtagPresenter

Returns a new instance of HashtagPresenter.


11
12
13
14
# File 'decidim-core/app/presenters/decidim/hashtag_presenter.rb', line 11

def initialize(hashtag, cased_name: nil)
  super(hashtag)
  @cased_name = cased_name if cased_name&.downcase == hashtag.name
end

Instance Method Details

#display_hashtagObject


29
30
31
# File 'decidim-core/app/presenters/decidim/hashtag_presenter.rb', line 29

def display_hashtag
  link_to name, decidim.search_path(term: name), target: "_blank", class: "hashtag-mention", rel: "noopener"
end

#display_hashtag_nameObject


33
34
35
# File 'decidim-core/app/presenters/decidim/hashtag_presenter.rb', line 33

def display_hashtag_name
  name
end

#hashtag_pathObject


25
26
27
# File 'decidim-core/app/presenters/decidim/hashtag_presenter.rb', line 25

def hashtag_path
  decidim.hashtag_path(__getobj__.name)
end

#nameObject

hashtag presented in a twitter-like style


19
20
21
# File 'decidim-core/app/presenters/decidim/hashtag_presenter.rb', line 19

def name
  "##{@cased_name || super}"
end