Sha256: eb7765a9f8ec9016ae0f8ad4787dc87413e0587c23d07b4603f1965b8df18cd7

Contents?: true

Size: 455 Bytes

Versions: 74

Compression:

Stored size: 455 Bytes

Contents

# frozen_string_literal: true

class Bookmark < ApplicationRecord
  belongs_to :user, polymorphic: true
  belongs_to :document, polymorphic: true

  validates :user_id, presence: true

  def document
    document_type.new document_type.unique_key => document_id
  end

  def document_type
    value = super if defined?(super)
    value &&= value.constantize
    value || default_document_type
  end

  def default_document_type
    SolrDocument
  end
end

Version data entries

74 entries across 74 versions & 2 rubygems

Version Path
blacklight-7.7.0 app/models/bookmark.rb
blacklight-7.6.0 app/models/bookmark.rb
blacklight-7.5.1 app/models/bookmark.rb
blacklight-7.5.0 app/models/bookmark.rb
blacklight-7.4.2 app/models/bookmark.rb
blacklight-7.4.1 app/models/bookmark.rb
blacklight-7.4.0 app/models/bookmark.rb
blacklight-7.3.0 app/models/bookmark.rb
blacklight-7.2.0 app/models/bookmark.rb
blacklight-7.1.0 app/models/bookmark.rb
blacklight-7.1.0.alpha app/models/bookmark.rb
blacklight-7.0.1 app/models/bookmark.rb
blacklight-7.0.0 app/models/bookmark.rb
blacklight-7.0.0.rc2 app/models/bookmark.rb