Class: Blacklight::Document::BookmarkComponent

Inherits:
ActionComponent show all
Defined in:
app/components/blacklight/document/bookmark_component.rb

Overview

Render a bookmark widget to bookmark / unbookmark a document

Constant Summary

Constants inherited from Component

Component::EXCLUDE_VARIABLES

Instance Method Summary collapse

Methods inherited from ActionComponent

#key, #label, #link_to_modal_control, #render_control, #render_partial, #url, #using_default_document_action?

Methods inherited from Component

compiler, config, #inspect

Constructor Details

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

Returns a new instance of BookmarkComponent.

Parameters:



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

def initialize(document:, action: nil, checked: nil, bookmark_path: nil, **kwargs)
  @document = document
  @checked = checked
  @bookmark_path = bookmark_path
  super(document: document, action: action, **kwargs)
end

Instance Method Details

#bookmark_pathObject



24
25
26
# File 'app/components/blacklight/document/bookmark_component.rb', line 24

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

#bookmarked?Boolean

Returns:

  • (Boolean)


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

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

  helpers.bookmarked? @document
end