module Decidim::Events::AuthorEvent

This module is used to be included in event classes inheriting from SimpleEvent whose resource has an author.

It adds the author_name, author_nickname, author_path and author_url to the i18n interpolations.

Public Instance Methods

author() click to toggle source
# File lib/decidim/events/author_event.rb, line 37
def author
  return unless resource.respond_to?(:author)
  return unless resource.author.is_a?(Decidim::UserBaseEntity)

  resource.author
end
author_name() click to toggle source
# File lib/decidim/events/author_event.rb, line 19
def author_name
  author_presenter&.name.to_s
end
author_nickname() click to toggle source
# File lib/decidim/events/author_event.rb, line 15
def author_nickname
  author_presenter&.nickname.to_s
end
author_path() click to toggle source
# File lib/decidim/events/author_event.rb, line 23
def author_path
  author_presenter&.profile_path.to_s
end
author_presenter() click to toggle source
# File lib/decidim/events/author_event.rb, line 31
def author_presenter
  return unless author

  @author_presenter ||= Decidim::UserPresenter.new(author)
end
author_url() click to toggle source
# File lib/decidim/events/author_event.rb, line 27
def author_url
  author_presenter&.profile_url.to_s
end