-
Notifications
You must be signed in to change notification settings - Fork 49
/
pdf_behavior.rb
40 lines (31 loc) · 1.12 KB
/
pdf_behavior.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# frozen_string_literal: true
module RDF
class CustomShowPdfViewerTerm < Vocabulary('http://id.loc.gov/vocabulary/identifiers/')
property 'show_pdf_viewer'
end
class CustomShowPdfDownloadButtonTerm < Vocabulary('http://id.loc.gov/vocabulary/identifiers/')
property 'show_pdf_download_button'
end
end
module PdfBehavior
extend ActiveSupport::Concern
included do
property :show_pdf_viewer, predicate: RDF::CustomShowPdfViewerTerm.show_pdf_viewer, multiple: false do |index|
index.as :stored_searchable
end
# rubocop:disable Metrics/LineLength
property :show_pdf_download_button, predicate: RDF::CustomShowPdfDownloadButtonTerm.show_pdf_download_button, multiple: false do |index|
index.as :stored_searchable
end
# rubocop:enable Metrics/LineLength
after_initialize :set_default_show_pdf_viewer, :set_default_show_pdf_download_button
end
private
# This is here so that the checkbox is checked by default
def set_default_show_pdf_viewer
self.show_pdf_viewer ||= '1'
end
def set_default_show_pdf_download_button
self.show_pdf_download_button ||= '1'
end
end