Sha256: 83a35127ffa663da870ac9be687b0075738aebea1fc6c79f908034a61c271acc

Contents?: true

Size: 581 Bytes

Versions: 43

Compression:

Stored size: 581 Bytes

Contents

# frozen_string_literal: true
class Bookmark < ActiveRecord::Base
  
  belongs_to :user, polymorphic: true
  belongs_to :document, polymorphic: true

  validates :user_id, presence: true

  if Blacklight::Utils.needs_attr_accessible?
    attr_accessible :id, :document_id, :document_type, :title
  end

  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

43 entries across 43 versions & 1 rubygems

Version Path
blacklight-6.0.2 app/models/bookmark.rb
blacklight-6.0.1 app/models/bookmark.rb
blacklight-6.0.0 app/models/bookmark.rb