Sha256: 11f750633356077740ac1c1be82bc5841ea325ef176ef1d35567696c8f6f486a

Contents?: true

Size: 816 Bytes

Versions: 18

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

18 entries across 18 versions & 1 rubygems

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