Class: User

Inherits:
ApplicationRecord show all
Includes:
Blacklight::User
Defined in:
app/models/user.rb

Overview

User

Instance Method Summary collapse

Instance Method Details

#bookmarks_for_documents(documents = []) ⇒ Object



15
16
17
18
19
20
21
# File 'app/models/user.rb', line 15

def bookmarks_for_documents(documents = [])
  if documents.any?
    bookmarks.where(document_type: documents.first.class.base_class.to_s, document_id: documents.map(&:id))
  else
    []
  end
end

#document_is_bookmarked?(document) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/models/user.rb', line 23

def document_is_bookmarked?(document)
  bookmarks_for_documents([document]).any?
end