Sha256: 7bf57cf01dbe6264fd711edbf6bd92c01a920121f7bd09bd6467993decf78263

Contents?: true

Size: 813 Bytes

Versions: 37

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Comments
    class CommentVotedEvent < Decidim::Events::SimpleEvent
      include Decidim::Comments::CommentEvent

      i18n_attributes :upvotes
      i18n_attributes :downvotes

      def initialize(resource:, event_name:, user:, user_role: nil, extra: nil)
        resource = target_resource(resource)
        super
      end

      def upvotes
        extra[:upvotes]
      end

      def downvotes
        extra[:downvotes]
      end

      def perform_translation?
        false
      end

      private

      def resource_url_params
        { anchor: "comment_#{comment.id}" }
      end

      def target_resource(t_resource)
        t_resource.is_a?(Decidim::Comments::Comment) ? t_resource.root_commentable : t_resource
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
decidim-comments-0.29.1 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.28.4 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.27.9 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.29.0 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.28.3 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.27.8 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.29.0.rc4 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.29.0.rc3 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.29.0.rc2 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.29.0.rc1 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.28.2 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.27.7 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.28.1 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.27.6 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.26.10 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.26.9 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.28.0 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.27.5 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.28.0.rc5 app/events/decidim/comments/comment_voted_event.rb
decidim-comments-0.28.0.rc4 app/events/decidim/comments/comment_voted_event.rb