Class: Decidim::HashtagPresenter

Inherits:
SimpleDelegator
  • Object
show all
Includes:
ActionView::Helpers::UrlHelper
Defined in:
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 '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 'app/presenters/decidim/hashtag_presenter.rb', line 29

def display_hashtag
  link_to name, decidim.search_path(term: name), target: "_blank", class: "text-secondary underline", rel: "noopener", data: { "external-link": false }
end

#display_hashtag_nameObject



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

def display_hashtag_name
  name
end

#hashtag_pathObject



25
26
27
# File '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 'app/presenters/decidim/hashtag_presenter.rb', line 19

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