Module: Blacklight::User

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/blacklight/user.rb

Instance Method Summary collapse

Instance Method Details

#bookmarks_for_documents(documents = []) ⇒ Object



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

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)


22
23
24
# File 'app/models/concerns/blacklight/user.rb', line 22

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

#existing_bookmark_for(document) ⇒ Object

returns a Bookmark object if there is one for document_id, else nil.



28
29
30
# File 'app/models/concerns/blacklight/user.rb', line 28

def existing_bookmark_for(document)
  bookmarks_for_documents([document]).first
end

#to_sString

Returns a user-displayable login/identifier for the user account.

Returns:

  • (String)

    a user-displayable login/identifier for the user account



34
35
36
37
38
39
# File 'app/models/concerns/blacklight/user.rb', line 34

def to_s
  string_display_key = self.class.string_display_key
  return send(string_display_key) if respond_to?(string_display_key)

  super
end