Module: Geoblacklight::SolrDocument
- Extended by:
- ActiveSupport::Concern, Blacklight::Solr::Document
- Includes:
- Arcgis, Citation, Finder, Inspection
- Defined in:
- app/models/concerns/geoblacklight/solr_document.rb,
app/models/concerns/geoblacklight/solr_document/arcgis.rb,
app/models/concerns/geoblacklight/solr_document/finder.rb,
app/models/concerns/geoblacklight/solr_document/citation.rb,
app/models/concerns/geoblacklight/solr_document/inspection.rb
Overview
Extends Blacklight::Solr::Document for GeoBlacklight specific functionality
Defined Under Namespace
Modules: Arcgis, Citation, Finder, Inspection
Class Method Summary
collapse
-
.warn_about_url_reader(method) ⇒ Object
Warn once per reader name rather than once per document: a search results page would otherwise emit one warning per result, because ActiveSupport::Deprecation does not deduplicate.
Instance Method Summary
collapse
Methods included from Citation
#geoblacklight_citation
Methods included from Arcgis
#arcgis_urls
Methods included from Inspection
#inspectable?
Methods included from Finder
#blacklight_solr
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Class Method Details
.warn_about_url_reader(method) ⇒ Object
Warn once per reader name rather than once per document: a search results page
would otherwise emit one warning per result, because
ActiveSupport::Deprecation does not deduplicate.
39
40
41
42
43
44
45
46
47
48
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 39
def self.warn_about_url_reader(method)
@warned_url_readers ||= Set.new
return unless @warned_url_readers.add?(method)
Geoblacklight.deprecation.warn(
"SolrDocument##{method} is resolved dynamically by Geoblacklight::SolrDocument#method_missing, " \
"which GeoBlacklight 6 removes; call references.#{method.to_s.delete_suffix("_url")}&.endpoint " \
"instead"
)
end
|
Instance Method Details
#available? ⇒ Boolean
50
51
52
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 50
def available?
public? || same_institution?
end
|
#checked_endpoint(type) ⇒ Object
Provides a convenience method to access a SolrDocument's References
endpoint url without having to check and see if it is available
:type => a string which if its a Geoblacklight::Constants::URI key
will return a coresponding Geoblacklight::Reference
111
112
113
114
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 111
def checked_endpoint(type)
type = references.public_send(type)
type.endpoint if type.present?
end
|
#data_dictionary_download ⇒ Object
86
87
88
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 86
def data_dictionary_download
references.data_dictionary.to_hash if references.data_dictionary.present?
end
|
#direct_download ⇒ Object
70
71
72
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 70
def direct_download
references.download.to_hash if references.download.present?
end
|
#downloadable? ⇒ Boolean
62
63
64
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 62
def downloadable?
Geoblacklight.deprecation.silence { direct_download || download_types.present? || iiif_download } && available?
end
|
#external_url ⇒ Object
90
91
92
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 90
def external_url
references.url&.endpoint
end
|
#geometry ⇒ Object
102
103
104
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 102
def geometry
@geometry ||= Geoblacklight::Geometry.new(geom_field)
end
|
#iiif_download ⇒ Object
82
83
84
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 82
def iiif_download
references.iiif.to_hash if references.iiif.present?
end
|
#item_viewer ⇒ Object
94
95
96
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 94
def item_viewer
ItemViewer.new(references)
end
|
#itemtype ⇒ Object
98
99
100
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 98
def itemtype
"http://schema.org/Dataset"
end
|
#oembed ⇒ Object
74
75
76
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 74
def oembed
references.oembed.endpoint if references.oembed.present?
end
|
#public? ⇒ Boolean
54
55
56
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 54
def public?
rights_field_data&.casecmp?("public")
end
|
#references ⇒ Object
66
67
68
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 66
def references
References.new(self)
end
|
#restricted? ⇒ Boolean
58
59
60
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 58
def restricted?
!rights_field_data || rights_field_data.casecmp?("restricted")
end
|
#same_institution? ⇒ Boolean
78
79
80
|
# File 'app/models/concerns/geoblacklight/solr_document.rb', line 78
def same_institution?
provider&.casecmp?(Settings.INSTITUTION.downcase)
end
|