Module: Blacklight::User
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/blacklight/user.rb
Instance Method Summary collapse
- #bookmarks_for_documents(documents = []) ⇒ Object
- #document_is_bookmarked?(document) ⇒ Boolean
-
#existing_bookmark_for(document) ⇒ Object
returns a Bookmark object if there is one for document_id, else nil.
-
#to_s ⇒ String
A user-displayable login/identifier for the user account.
Instance Method Details
#bookmarks_for_documents(documents = []) ⇒ Object
50 51 52 53 54 55 56 |
# File 'app/models/concerns/blacklight/user.rb', line 50 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
58 59 60 |
# File 'app/models/concerns/blacklight/user.rb', line 58 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.
64 65 66 |
# File 'app/models/concerns/blacklight/user.rb', line 64 def existing_bookmark_for(document) bookmarks_for_documents([document]).first end |
#to_s ⇒ String
Returns a user-displayable login/identifier for the user account.
70 71 72 73 74 75 |
# File 'app/models/concerns/blacklight/user.rb', line 70 def to_s string_display_key = self.class.string_display_key return send(string_display_key) if respond_to?(string_display_key) super end |