Class: Blacklight::Document::BookmarkComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/blacklight/document/bookmark_component.rb

Overview

Render a bookmark widget to bookmark / unbookmark a document

Instance Method Summary collapse

Methods inherited from Component

reset_compiler!, sidecar_files, upstream_sidecar_files

Constructor Details

#initialize(document:, checked: nil, bookmark_path: nil) ⇒ BookmarkComponent

Returns a new instance of BookmarkComponent.

Parameters:

  • document (Blacklight::Document)
  • checked (Boolean) (defaults to: nil)
  • bookmark_path (Object) (defaults to: nil)

    the rails route to use for bookmarks



10
11
12
13
14
# File 'app/components/blacklight/document/bookmark_component.rb', line 10

def initialize(document:, checked: nil, bookmark_path: nil)
  @document = document
  @checked = checked
  @bookmark_path = bookmark_path
end

Instance Method Details

#bookmark_pathObject



22
23
24
# File 'app/components/blacklight/document/bookmark_component.rb', line 22

def bookmark_path
  @bookmark_path || helpers.bookmark_path(@document)
end

#bookmarked?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'app/components/blacklight/document/bookmark_component.rb', line 16

def bookmarked?
  return @checked unless @checked.nil?

  helpers.bookmarked? @document
end