Sha256: 08c1291ff9f5f749c148cd490606b34807e39b1109e091f633a01daf71210b3e

Contents?: true

Size: 816 Bytes

Versions: 13

Compression:

Stored size: 816 Bytes

Contents

# frozen_string_literal: true

module Decidim
  class ResourceEndorsedEvent < Decidim::Events::SimpleEvent
    i18n_attributes :endorser_nickname, :endorser_name, :endorser_path, :nickname, :resource_type

    delegate :nickname, :name, to: :endorser, prefix: true

    def nickname
      endorser_nickname
    end

    def endorser_path
      endorser.profile_path
    end

    def resource_text
      return resource.body if resource.respond_to? :body
      return resource.description if resource.respond_to? :description
    end

    def resource_type
      resource.class.model_name.human
    end

    private

    def endorser
      @endorser ||= Decidim::UserPresenter.new(endorser_user)
    end

    def endorser_user
      @endorser_user ||= Decidim::User.find_by(id: extra[:endorser_id])
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/events/decidim/resource_endorsed_event.rb
decidim-core-0.28.4 app/events/decidim/resource_endorsed_event.rb
decidim-core-0.29.0 app/events/decidim/resource_endorsed_event.rb
decidim-core-0.28.3 app/events/decidim/resource_endorsed_event.rb
decidim-core-0.29.0.rc4 app/events/decidim/resource_endorsed_event.rb
decidim-core-0.29.0.rc3 app/events/decidim/resource_endorsed_event.rb
decidim-core-0.29.0.rc2 app/events/decidim/resource_endorsed_event.rb
decidim-core-0.29.0.rc1 app/events/decidim/resource_endorsed_event.rb
decidim-core-0.28.2 app/events/decidim/resource_endorsed_event.rb
decidim-core-0.28.1 app/events/decidim/resource_endorsed_event.rb
decidim-core-0.28.0 app/events/decidim/resource_endorsed_event.rb
decidim-core-0.28.0.rc5 app/events/decidim/resource_endorsed_event.rb
decidim-core-0.28.0.rc4 app/events/decidim/resource_endorsed_event.rb