Sha256: f0f614a2e36e3e5e0f82cbedacf774fce0147d5553510afe63de8ee48417b2e2

Contents?: true

Size: 1.22 KB

Versions: 14

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  module Comments
    # Shared behaviour for commentable models.
    module Commentable
      extend ActiveSupport::Concern
      include Decidim::Notifiable

      included do
        has_many :comments, as: :commentable, foreign_key: "decidim_commentable_id", foreign_type: "decidim_commentable_type", class_name: "Decidim::Comments::Comment"

        # Public: Whether the object's comments are visible or not.
        def commentable?
          true
        end

        # Public: Whether the object can have new comments or not.
        def accepts_new_comments?
          true
        end

        # Public: Whether the object's comments can have alignment or not. It enables the
        # alignment selector in the add new comment form.
        def comments_have_alignment?
          false
        end

        # Public: Whether the object's comments can have have votes or not. It enables the
        # upvote and downvote buttons for comments.
        def comments_have_votes?
          false
        end

        # Public: Identifies the commentable type in the API.
        def commentable_type
          self.class.name
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
decidim-comments-0.5.1 lib/decidim/comments/commentable.rb
decidim-0.5.1 decidim-comments/lib/decidim/comments/commentable.rb
decidim-comments-0.5.0 lib/decidim/comments/commentable.rb
decidim-0.5.0 decidim-comments/lib/decidim/comments/commentable.rb
decidim-comments-0.4.4 lib/decidim/comments/commentable.rb
decidim-0.4.4 decidim-comments/lib/decidim/comments/commentable.rb
decidim-comments-0.4.3 lib/decidim/comments/commentable.rb
decidim-comments-0.4.2 lib/decidim/comments/commentable.rb
decidim-comments-0.4.1 lib/decidim/comments/commentable.rb
decidim-0.4.3 decidim-comments/lib/decidim/comments/commentable.rb
decidim-0.4.2 decidim-comments/lib/decidim/comments/commentable.rb
decidim-0.4.1 decidim-comments/lib/decidim/comments/commentable.rb
decidim-comments-0.4.0 lib/decidim/comments/commentable.rb
decidim-0.4.0 decidim-comments/lib/decidim/comments/commentable.rb