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?
188 189 190 |
# File 'lib/cocina_display/concerns/accesses.rb', line 188 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)?
157 158 159 |
# File 'lib/cocina_display/concerns/accesses.rb', line 157 def dark_access? !viewable? && !downloadable? end |
#download_rights ⇒ String?
Individual files may have differing download rights.
Download rights for the object.
78 79 80 |
# File 'lib/cocina_display/concerns/accesses.rb', line 78 def download_rights path("$.access.download").first end |
#downloadable? ⇒ Boolean
Is the object downloadable in some capacity?
97 98 99 |
# File 'lib/cocina_display/concerns/accesses.rb', line 97 def downloadable? 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?
175 176 177 |
# File 'lib/cocina_display/concerns/accesses.rb', line 175 def location_only_access? location_only_viewable? && location_only_downloadable? end |
#location_only_downloadable? ⇒ Boolean
Is the object downloadable only if in a location?
169 170 171 |
# File 'lib/cocina_display/concerns/accesses.rb', line 169 def location_only_downloadable? download_rights == "location-based" end |
#location_only_viewable? ⇒ Boolean
Is the object viewable only if in a location?
163 164 165 |
# File 'lib/cocina_display/concerns/accesses.rb', line 163 def location_only_viewable? view_rights == "location-based" end |
#location_rights ⇒ String?
If access or download is location-based, which location has access.
85 86 87 |
# File 'lib/cocina_display/concerns/accesses.rb', line 85 def location_rights path("$.access.location").first end |
#stanford_access? ⇒ Boolean
Is the object both viewable and downloadable by Stanford affiliates?
151 152 153 |
# File 'lib/cocina_display/concerns/accesses.rb', line 151 def stanford_access? stanford_viewable? && stanford_downloadable? end |
#stanford_downloadable? ⇒ Boolean
Is the object downloadable by Stanford affiliates?
145 146 147 |
# File 'lib/cocina_display/concerns/accesses.rb', line 145 def stanford_downloadable? world_downloadable? || stanford_only_downloadable? end |
#stanford_only_access? ⇒ Boolean
Is the object only viewable and downloadable by Stanford affiliates?
133 134 135 |
# File 'lib/cocina_display/concerns/accesses.rb', line 133 def stanford_only_access? stanford_only_viewable? && stanford_only_downloadable? end |
#stanford_only_downloadable? ⇒ Boolean
Is the object only downloadable by Stanford affiliates?
127 128 129 |
# File 'lib/cocina_display/concerns/accesses.rb', line 127 def stanford_only_downloadable? download_rights == "stanford" end |
#stanford_only_viewable? ⇒ Boolean
Is the object only viewable by Stanford affiliates?
121 122 123 |
# File 'lib/cocina_display/concerns/accesses.rb', line 121 def stanford_only_viewable? view_rights == "stanford" end |
#stanford_viewable? ⇒ Boolean
Is the object viewable by Stanford affiliates?
139 140 141 |
# File 'lib/cocina_display/concerns/accesses.rb', line 139 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?
91 92 93 |
# File 'lib/cocina_display/concerns/accesses.rb', line 91 def viewable? view_rights != "dark" end |
#viewable_at_location?(location) ⇒ Boolean
Is the object viewable at the given location?
182 183 184 |
# File 'lib/cocina_display/concerns/accesses.rb', line 182 def viewable_at_location?(location) world_viewable? || stanford_viewable? || location_rights == location end |
#world_access? ⇒ Boolean
Is the object both viewable and downloadable by anyone?
115 116 117 |
# File 'lib/cocina_display/concerns/accesses.rb', line 115 def world_access? world_viewable? && world_downloadable? end |
#world_downloadable? ⇒ Boolean
Is the object downloadable by anyone?
109 110 111 |
# File 'lib/cocina_display/concerns/accesses.rb', line 109 def world_downloadable? download_rights == "world" end |
#world_viewable? ⇒ Boolean
Is the object viewable by anyone?
103 104 105 |
# File 'lib/cocina_display/concerns/accesses.rb', line 103 def world_viewable? view_rights == "world" end |