Sha256: e7c9b73b56fa9360564e0d5d38a024cb56e68bf210429494b622c8db61d00ecf

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

# frozen-string_literal: true

module Decidim::Amendable
  class AmendmentBaseEvent < Decidim::Events::SimpleEvent
    i18n_attributes :amendable_path, :amendable_type, :amendable_title, :emendation_path, :emendation_author_nickname, :emendation_author_path

    def amendable_title
      @amendable_title ||= amendable_resource.title
    end

    def amendable_type
      @amendable_type ||= I18n.t(amendable_resource.class.model_name.i18n_key, scope: "activerecord.models", count: 1).downcase
    end

    def amendable_path
      @amendable_path ||= Decidim::ResourceLocatorPresenter.new(amendable_resource).path
    end

    def emendation_author
      @emendation_author ||= if emendation_resource.is_a?(Decidim::Coauthorable)
                               Decidim::UserPresenter.new(emendation_resource.creator_author)
                             else
                               Decidim::UserPresenter.new(emendation_resource.author)
                             end
    end

    def emendation_author_nickname
      @emendation_author_nickname ||= emendation_author.nickname
    end

    def emendation_author_path
      @emendation_author_path ||= emendation_author.profile_path
    end

    def emendation_path
      @emendation_path ||= Decidim::ResourceLocatorPresenter.new(emendation_resource).path
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-core-0.17.2 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.17.1 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.16.1 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.17.0 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.16.0 app/events/decidim/amendable/amendment_base_event.rb