Sha256: deb688d7983799d58c4971f57713333e6808ac7174e1978b8cc45d28f4fedacf

Contents?: true

Size: 1.18 KB

Versions: 64

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Decidim
  module Events
    # This module is used to be included in event classes inheriting from SimpleEvent
    # whose resource is coauthorable.
    #
    # It adds the following methods related with the creator author: author_name, author_nickname, author_path and author_url to the i18n interpolations.
    module CoauthorEvent
      extend ActiveSupport::Concern

      included do
        i18n_attributes :author_name, :author_nickname, :author_path, :author_url

        def author_nickname
          author_presenter&.nickname.to_s
        end

        def author_name
          author_presenter&.name.to_s
        end

        def author_path
          author_presenter&.profile_path.to_s
        end

        def author_url
          author_presenter&.profile_url.to_s
        end

        def author_presenter
          return unless author

          @author_presenter ||= Decidim::UserPresenter.new(author)
        end

        def author
          return unless resource.respond_to?(:creator_author)
          return unless resource.creator_author.is_a?(Decidim::UserBaseEntity)

          resource.creator_author
        end
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
decidim-core-0.29.1 lib/decidim/events/coauthor_event.rb
decidim-core-0.28.4 lib/decidim/events/coauthor_event.rb
decidim-core-0.27.9 lib/decidim/events/coauthor_event.rb
decidim-core-0.29.0 lib/decidim/events/coauthor_event.rb
decidim-core-0.28.3 lib/decidim/events/coauthor_event.rb
decidim-core-0.27.8 lib/decidim/events/coauthor_event.rb
decidim-core-0.29.0.rc4 lib/decidim/events/coauthor_event.rb
decidim-core-0.29.0.rc3 lib/decidim/events/coauthor_event.rb
decidim-core-0.29.0.rc2 lib/decidim/events/coauthor_event.rb
decidim-core-0.29.0.rc1 lib/decidim/events/coauthor_event.rb
decidim-core-0.28.2 lib/decidim/events/coauthor_event.rb
decidim-core-0.27.7 lib/decidim/events/coauthor_event.rb
decidim-core-0.28.1 lib/decidim/events/coauthor_event.rb
decidim-core-0.27.6 lib/decidim/events/coauthor_event.rb
decidim-core-0.26.10 lib/decidim/events/coauthor_event.rb
decidim-core-0.26.9 lib/decidim/events/coauthor_event.rb
decidim-core-0.28.0 lib/decidim/events/coauthor_event.rb
decidim-core-0.27.5 lib/decidim/events/coauthor_event.rb
decidim-core-0.28.0.rc5 lib/decidim/events/coauthor_event.rb
decidim-core-0.28.0.rc4 lib/decidim/events/coauthor_event.rb