Sha256: 35ce872efcbbdb3e97bb7fe3f65a26d9af0722510c42146ce5c97cfab158b7c1

Contents?: true

Size: 880 Bytes

Versions: 4

Compression:

Stored size: 880 Bytes

Contents

module RailsAdminComments
  module ModelComments
    module Mongoid
      extend ActiveSupport::Concern
      included do
        include ::Mongoid::Document
        include ::Mongoid::Timestamps::Short
        include ::Mongoid::Userstamp

        field :model_name, type: String

        store_in collection: "rails_admin_model_comments"

        field :enabled, type: ::Mongoid::VERSION.to_i < 4 ? Boolean : ::Mongoid::Boolean, default: true
        scope :enabled, -> { where(enabled: true) }

        scope :by_date, -> { order([:c_at, :asc]) }

        field :content
        validates_presence_of :content

        has_and_belongs_to_many :visible_for_users, class_name: "User", inverse_of: nil
        scope :for_user, ->(user) {
          any_of({visible_for_user_ids: user}, {visible_for_user_ids: nil}, {visible_for_user_ids: []})
        }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_admin_comments-0.2.3.3 lib/rails_admin_comments/models/mongoid/model_comments.rb
rails_admin_comments-0.3.0.4 lib/rails_admin_comments/models/mongoid/model_comments.rb
rails_admin_comments-0.2.3.2 lib/rails_admin_comments/models/mongoid/model_comments.rb
rails_admin_comments-0.3.0.3 lib/rails_admin_comments/models/mongoid/model_comments.rb