Module: CurationConcerns::SolrDocumentBehavior
- Extended by:
- ActiveSupport::Concern
- Includes:
- Hydra::Works::MimeTypes
- Defined in:
- app/models/concerns/curation_concerns/solr_document_behavior.rb
Instance Method Summary collapse
- #collection? ⇒ Boolean
- #contributor ⇒ Object
- #creator ⇒ Object
- #date_created ⇒ Object
- #date_modified ⇒ Object
- #date_uploaded ⇒ Object
- #depositor(default = '') ⇒ Object
- #description ⇒ Object
- #embargo_release_date ⇒ Object
- #file_format ⇒ Object
- #human_readable_type ⇒ Object
-
#hydra_model ⇒ Object
Method to return the ActiveFedora model.
- #label ⇒ Object
- #language ⇒ Object
- #lease_expiration_date ⇒ Object
- #mime_type ⇒ Object
- #publisher ⇒ Object
- #read_groups ⇒ Object
- #representative_id ⇒ Object
- #rights ⇒ Object
- #subject ⇒ Object
- #tags ⇒ Object
- #title ⇒ Object
- #title_or_label ⇒ Object
-
#to_model ⇒ Object
Offer the source (ActiveFedora-based) model to Rails for some of the Rails methods (e.g. link_to).
- #to_param ⇒ Object
- #to_s ⇒ Object
- #visibility ⇒ Object
Instance Method Details
#collection? ⇒ Boolean
30 31 32 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 30 def collection? hydra_model == 'Collection' end |
#contributor ⇒ Object
84 85 86 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 84 def contributor fetch(Solrizer.solr_name('contributor'), []) end |
#creator ⇒ Object
80 81 82 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 80 def creator fetch(Solrizer.solr_name('creator'), []) end |
#date_created ⇒ Object
47 48 49 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 47 def date_created date_field('date_created') end |
#date_modified ⇒ Object
51 52 53 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 51 def date_modified date_field('date_modified') end |
#date_uploaded ⇒ Object
55 56 57 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 55 def date_uploaded date_field('date_uploaded') end |
#depositor(default = '') ⇒ Object
59 60 61 62 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 59 def depositor(default = '') val = Array(self[Solrizer.solr_name('depositor')]).first val.present? ? val : default end |
#description ⇒ Object
68 69 70 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 68 def description Array(self[Solrizer.solr_name('description')]).first end |
#embargo_release_date ⇒ Object
104 105 106 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 104 def self[Hydra.config...release_date] end |
#file_format ⇒ Object
76 77 78 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 76 def file_format Array(self[Solrizer.solr_name('file_format')]).first end |
#human_readable_type ⇒ Object
39 40 41 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 39 def human_readable_type Array(self[Solrizer.solr_name('human_readable_type', :stored_searchable)]).first end |
#hydra_model ⇒ Object
Method to return the ActiveFedora model
35 36 37 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 35 def hydra_model self[Solrizer.solr_name('active_fedora_model', Solrizer::Descriptor.new(:string, :stored, :indexed))] end |
#label ⇒ Object
72 73 74 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 72 def label Array(self[Solrizer.solr_name('label')]).first end |
#language ⇒ Object
96 97 98 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 96 def language fetch(Solrizer.solr_name('language'), []) end |
#lease_expiration_date ⇒ Object
108 109 110 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 108 def lease_expiration_date self[Hydra.config..lease.expiration_date] end |
#mime_type ⇒ Object
116 117 118 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 116 def mime_type self[Solrizer.solr_name('mime_type', :stored_sortable)] end |
#publisher ⇒ Object
92 93 94 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 92 def publisher fetch(Solrizer.solr_name('publisher'), []) end |
#read_groups ⇒ Object
120 121 122 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 120 def read_groups fetch(Hydra.config..read.group, []) end |
#representative_id ⇒ Object
43 44 45 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 43 def representative_id fetch(Solrizer.solr_name('hasRelatedMediaFragment', :symbol), []).first end |
#rights ⇒ Object
112 113 114 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 112 def rights self[Solrizer.solr_name('rights')] end |
#subject ⇒ Object
88 89 90 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 88 def subject fetch(Solrizer.solr_name('subject'), []) end |
#tags ⇒ Object
100 101 102 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 100 def fetch(Solrizer.solr_name('tag'), []) end |
#title ⇒ Object
64 65 66 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 64 def title Array(self[Solrizer.solr_name('title')]).first end |
#title_or_label ⇒ Object
6 7 8 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 6 def title_or_label title || label end |
#to_model ⇒ Object
Offer the source (ActiveFedora-based) model to Rails for some of the Rails methods (e.g. link_to).
23 24 25 26 27 28 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 23 def to_model @model ||= begin m = ActiveFedora::Base.load_instance_from_solr(id, self) m.class == ActiveFedora::Base ? self : m end end |
#to_param ⇒ Object
10 11 12 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 10 def to_param id end |
#to_s ⇒ Object
14 15 16 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 14 def to_s title_or_label end |
#visibility ⇒ Object
124 125 126 127 128 129 130 131 132 |
# File 'app/models/concerns/curation_concerns/solr_document_behavior.rb', line 124 def visibility @visibility ||= if read_groups.include? Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_PUBLIC Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC elsif read_groups.include? Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED else Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE end end |