Sha256: 2bc83f51cfb8c2f7485bdce2f1b8c2773f2b70e3b85a8c081f9dd911cec9fab4

Contents?: true

Size: 1.46 KB

Versions: 21

Compression:

Stored size: 1.46 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 ||= translated_attribute(amendable_resource.title)
    end

    def amendable_type
      @amendable_type ||= amendable_resource.class.model_name.human.downcase
    end

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

    def emendation_author
      return unless emendation_resource

      @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
      return unless emendation_resource

      @emendation_author_nickname ||= emendation_author.nickname
    end

    def emendation_author_path
      return unless emendation_resource

      @emendation_author_path ||= emendation_author.profile_path
    end

    def emendation_path
      return unless emendation_resource

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

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.27.8 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.27.7 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.27.6 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.26.10 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.26.9 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.27.5 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.26.8 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.27.4 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.27.3 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.26.7 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.26.5 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.27.2 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.27.1 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.26.4 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.27.0 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.26.3 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.27.0.rc2 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.27.0.rc1 app/events/decidim/amendable/amendment_base_event.rb
decidim-core-0.26.2 app/events/decidim/amendable/amendment_base_event.rb