Sha256: 533b779691f5ec141c9678ab3d19c0f3ec1fe098e072adcaa5bfee96337945a9

Contents?: true

Size: 839 Bytes

Versions: 28

Compression:

Stored size: 839 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Gamification
    class BaseEvent < Decidim::Events::SimpleEvent
      i18n_attributes :badge_name, :current_level

      delegate :url_helpers, to: "Decidim::Core::Engine.routes"

      def resource_path
        url_helpers.profile_badges_path(nickname: user.nickname)
      end

      def resource_url
        url_helpers.profile_badges_url(
          nickname: user.nickname,
          host: user.organization.host
        )
      end

      private

      def badge_name
        I18n.t "#{badge.name}.name", scope: "decidim.gamification.badges"
      end

      def badge
        @badge ||= Gamification.find_badge(extra.dig("badge_name"))
      end

      def current_level
        extra.dig("current_level")
      end

      def user
        resource
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
decidim-core-0.23.6 lib/decidim/gamification/base_event.rb
decidim-core-0.23.5 lib/decidim/gamification/base_event.rb
decidim-core-0.23.4 lib/decidim/gamification/base_event.rb
decidim-core-0.23.3 lib/decidim/gamification/base_event.rb
decidim-core-0.23.2 lib/decidim/gamification/base_event.rb
decidim-core-0.23.1 lib/decidim/gamification/base_event.rb
decidim-core-0.23.1.rc1 lib/decidim/gamification/base_event.rb
decidim-core-0.23.0 lib/decidim/gamification/base_event.rb
decidim-core-0.22.0 lib/decidim/gamification/base_event.rb
decidim-core-0.21.0 lib/decidim/gamification/base_event.rb
decidim-core-0.20.1 lib/decidim/gamification/base_event.rb
decidim-core-0.20.0 lib/decidim/gamification/base_event.rb
decidim-core-0.19.1 lib/decidim/gamification/base_event.rb
decidim-core-0.18.1 lib/decidim/gamification/base_event.rb
decidim-core-0.19.0 lib/decidim/gamification/base_event.rb
decidim-core-0.17.2 lib/decidim/gamification/base_event.rb
decidim-core-0.18.0 lib/decidim/gamification/base_event.rb
decidim-core-0.17.1 lib/decidim/gamification/base_event.rb
decidim-core-0.16.1 lib/decidim/gamification/base_event.rb
decidim-core-0.17.0 lib/decidim/gamification/base_event.rb