Module: CocinaDisplay::Concerns::Accesses
- Included in:
- CocinaDisplay::CocinaRecord, RelatedResource
- Defined in:
- lib/cocina_display/concerns/accesses.rb
Overview
Methods for extracting access/location information from a Cocina object.
Instance Method Summary collapse
-
#access_contacts ⇒ Array<Description::AccessContact>
All access contact metadata.
-
#access_display_data ⇒ Array<DisplayData>
Display data for all access metadata except contact emails.
-
#accesses ⇒ Array<Description::Access>
All access metadata except contact emails and URLs.
-
#citation_only_access? ⇒ Boolean
Is the object only viewable for citation purposes?.
-
#contact_email_display_data ⇒ Array<DisplayData>
Display data for all access contact email metadata.
-
#copyright_display_data ⇒ Array<CocinaDisplay::DisplayData>
Display data for the copyright statement.
-
#dark_access? ⇒ Boolean
Is the object "dark" (not viewable or downloadable by anyone)?.
-
#download_rights ⇒ String?
Download rights for the object.
-
#downloadable? ⇒ Boolean
Is the object downloadable in some capacity?.
- #license_display_data ⇒ Object
-
#location_only_access? ⇒ Boolean
Is the object only viewable and downloadable if in a location?.
-
#location_only_downloadable? ⇒ Boolean
Is the object downloadable only if in a location?.
-
#location_only_viewable? ⇒ Boolean
Is the object viewable only if in a location?.
-
#location_rights ⇒ String?
If access or download is location-based, which location has access.
-
#stanford_access? ⇒ Boolean
Is the object both viewable and downloadable by Stanford affiliates?.
-
#stanford_downloadable? ⇒ Boolean
Is the object downloadable by Stanford affiliates?.
-
#stanford_only_access? ⇒ Boolean
Is the object only viewable and downloadable by Stanford affiliates?.
-
#stanford_only_downloadable? ⇒ Boolean
Is the object only downloadable by Stanford affiliates?.
-
#stanford_only_viewable? ⇒ Boolean
Is the object only viewable by Stanford affiliates?.
-
#stanford_viewable? ⇒ Boolean
Is the object viewable by Stanford affiliates?.
-
#urls ⇒ Array<Description::Url>
All access URL metadata.
-
#use_and_reproduction_display_data ⇒ Array<CocinaDisplay::DisplayData>
Display data for the use and reproduction statement.
-
#view_rights ⇒ String?
View rights for the object.
-
#viewable? ⇒ Boolean
Is the object viewable in some capacity?.
-
#viewable_at_location?(location) ⇒ Boolean
Is the object viewable at the given location?.
-
#world_access? ⇒ Boolean
Is the object both viewable and downloadable by anyone?.
-
#world_downloadable? ⇒ Boolean
Is the object downloadable by anyone?.
-
#world_viewable? ⇒ Boolean
Is the object viewable by anyone?.
Instance Method Details
#access_contacts ⇒ Array<Description::AccessContact>
All access contact metadata
53 54 55 56 57 |
# File 'lib/cocina_display/concerns/accesses.rb', line 53 def access_contacts path("$.description.access.accessContact.*").map do |contact| CocinaDisplay::Description::AccessContact.new(contact) end end |
#access_display_data ⇒ Array<DisplayData>
Display data for all access metadata except contact emails
7 8 9 10 11 12 |
# File 'lib/cocina_display/concerns/accesses.rb', line 7 def access_display_data CocinaDisplay::DisplayData.from_objects(accesses + access_contacts.reject(&:contact_email?) + purls + urls) end |
#accesses ⇒ Array<Description::Access>
All access metadata except contact emails and URLs
43 44 45 46 47 48 49 |
# File 'lib/cocina_display/concerns/accesses.rb', line 43 def accesses @accesses ||= Enumerator::Chain.new( path("$.description.access.physicalLocation.*"), path("$.description.access.digitalLocation.*"), path("$.description.access.digitalRepository.*") ).map { |a| CocinaDisplay::Description::Access.new(a) } end |
#citation_only_access? ⇒ Boolean
Is the object only viewable for citation purposes?
195 196 197 |
# File 'lib/cocina_display/concerns/accesses.rb', line 195 def citation_only_access? view_rights == "citation-only" end |
#contact_email_display_data ⇒ Array<DisplayData>
Display data for all access contact email metadata
16 17 18 |
# File 'lib/cocina_display/concerns/accesses.rb', line 16 def contact_email_display_data CocinaDisplay::DisplayData.from_objects(access_contacts.select(&:contact_email?)) end |
#copyright_display_data ⇒ Array<CocinaDisplay::DisplayData>
Display data for the copyright statement. Exhibits and EarthWorks handle copyright like descriptive metadata.
31 32 33 34 |
# File 'lib/cocina_display/concerns/accesses.rb', line 31 def copyright_display_data CocinaDisplay::DisplayData.from_strings([copyright], label: I18n.t("cocina_display.field_label.copyright")) end |
#dark_access? ⇒ Boolean
Is the object "dark" (not viewable or downloadable by anyone)?
164 165 166 |
# File 'lib/cocina_display/concerns/accesses.rb', line 164 def dark_access? !viewable? && !downloadable? end |
#download_rights ⇒ String?
Individual files may have differing download rights.
Collections have no download rights, so this is always nil for them.
Download rights for the object.
79 80 81 |
# File 'lib/cocina_display/concerns/accesses.rb', line 79 def download_rights path("$.access.download").first end |
#downloadable? ⇒ Boolean
Is the object downloadable in some capacity?
98 99 100 |
# File 'lib/cocina_display/concerns/accesses.rb', line 98 def downloadable? download_rights.present? && download_rights != "none" end |
#license_display_data ⇒ Object
36 37 38 39 |
# File 'lib/cocina_display/concerns/accesses.rb', line 36 def license_display_data CocinaDisplay::DisplayData.from_strings([license_description], label: I18n.t("cocina_display.field_label.license")) end |
#location_only_access? ⇒ Boolean
Is the object only viewable and downloadable if in a location?
182 183 184 |
# File 'lib/cocina_display/concerns/accesses.rb', line 182 def location_only_access? location_only_viewable? && location_only_downloadable? end |
#location_only_downloadable? ⇒ Boolean
Is the object downloadable only if in a location?
176 177 178 |
# File 'lib/cocina_display/concerns/accesses.rb', line 176 def location_only_downloadable? download_rights == "location-based" end |
#location_only_viewable? ⇒ Boolean
Is the object viewable only if in a location?
170 171 172 |
# File 'lib/cocina_display/concerns/accesses.rb', line 170 def location_only_viewable? view_rights == "location-based" end |
#location_rights ⇒ String?
If access or download is location-based, which location has access.
86 87 88 |
# File 'lib/cocina_display/concerns/accesses.rb', line 86 def location_rights path("$.access.location").first end |
#stanford_access? ⇒ Boolean
Collections have no download rights, so only view rights are considered.
Is the object both viewable and downloadable by Stanford affiliates?
156 157 158 159 160 |
# File 'lib/cocina_display/concerns/accesses.rb', line 156 def stanford_access? return stanford_viewable? if collection? stanford_viewable? && stanford_downloadable? end |
#stanford_downloadable? ⇒ Boolean
Is the object downloadable by Stanford affiliates?
149 150 151 |
# File 'lib/cocina_display/concerns/accesses.rb', line 149 def stanford_downloadable? world_downloadable? || stanford_only_downloadable? end |
#stanford_only_access? ⇒ Boolean
Is the object only viewable and downloadable by Stanford affiliates?
137 138 139 |
# File 'lib/cocina_display/concerns/accesses.rb', line 137 def stanford_only_access? stanford_only_viewable? && stanford_only_downloadable? end |
#stanford_only_downloadable? ⇒ Boolean
Is the object only downloadable by Stanford affiliates?
131 132 133 |
# File 'lib/cocina_display/concerns/accesses.rb', line 131 def stanford_only_downloadable? download_rights == "stanford" end |
#stanford_only_viewable? ⇒ Boolean
Is the object only viewable by Stanford affiliates?
125 126 127 |
# File 'lib/cocina_display/concerns/accesses.rb', line 125 def stanford_only_viewable? view_rights == "stanford" end |
#stanford_viewable? ⇒ Boolean
Is the object viewable by Stanford affiliates?
143 144 145 |
# File 'lib/cocina_display/concerns/accesses.rb', line 143 def stanford_viewable? world_viewable? || stanford_only_viewable? end |
#urls ⇒ Array<Description::Url>
All access URL metadata
61 62 63 64 65 |
# File 'lib/cocina_display/concerns/accesses.rb', line 61 def urls path("$.description.access.url.*").map do |url| CocinaDisplay::Description::Url.new(url) end end |
#use_and_reproduction_display_data ⇒ Array<CocinaDisplay::DisplayData>
Display data for the use and reproduction statement. Exhibits and EarthWorks handle useAndReproductionStatement like descriptive metadata.
23 24 25 26 |
# File 'lib/cocina_display/concerns/accesses.rb', line 23 def use_and_reproduction_display_data CocinaDisplay::DisplayData.from_strings([use_and_reproduction], label: I18n.t("cocina_display.field_label.use_and_reproduction")) end |
#view_rights ⇒ String?
View rights for the object.
70 71 72 |
# File 'lib/cocina_display/concerns/accesses.rb', line 70 def view_rights path("$.access.view").first end |
#viewable? ⇒ Boolean
Is the object viewable in some capacity?
92 93 94 |
# File 'lib/cocina_display/concerns/accesses.rb', line 92 def viewable? view_rights != "dark" end |
#viewable_at_location?(location) ⇒ Boolean
Is the object viewable at the given location?
189 190 191 |
# File 'lib/cocina_display/concerns/accesses.rb', line 189 def viewable_at_location?(location) world_viewable? || stanford_viewable? || location_rights == location end |
#world_access? ⇒ Boolean
Collections have no download rights, so only view rights are considered.
Is the object both viewable and downloadable by anyone?
117 118 119 120 121 |
# File 'lib/cocina_display/concerns/accesses.rb', line 117 def world_access? return world_viewable? if collection? world_viewable? && world_downloadable? end |
#world_downloadable? ⇒ Boolean
Is the object downloadable by anyone?
110 111 112 |
# File 'lib/cocina_display/concerns/accesses.rb', line 110 def world_downloadable? download_rights == "world" end |
#world_viewable? ⇒ Boolean
Is the object viewable by anyone?
104 105 106 |
# File 'lib/cocina_display/concerns/accesses.rb', line 104 def world_viewable? view_rights == "world" end |