Module: Spotlight::SolrDocument
- Extended by:
- ActiveSupport::Concern
- Includes:
- GlobalID::Identification, ActiveModelConcern, Finder, SpotlightImages
- Defined in:
- app/models/concerns/spotlight/solr_document.rb,
app/models/concerns/spotlight/solr_document/finder.rb,
app/models/concerns/spotlight/solr_document/atomic_updates.rb,
app/models/concerns/spotlight/solr_document/spotlight_images.rb,
app/models/concerns/spotlight/solr_document/uploaded_resource.rb,
app/models/concerns/spotlight/solr_document/active_model_concern.rb
Overview
SolrDocument mixins to add ActiveModel shims and indexing methods
Defined Under Namespace
Modules: ActiveModelConcern, AtomicUpdates, ClassMethods, Finder, SpotlightImages, UploadedResource
Instance Method Summary
collapse
#spotlight_image_versions
Methods included from Finder
#blacklight_solr
#destroyed?, #new_record?, #persisted?, #save, #to_key
Instance Method Details
#attribute_present?(*_args) ⇒ Boolean
108
109
110
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 108
def attribute_present?(*_args)
false
end
|
#make_private!(exhibit) ⇒ Object
91
92
93
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 91
def make_private!(exhibit)
sidecar(exhibit).private!
end
|
#make_public!(exhibit) ⇒ Object
87
88
89
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 87
def make_public!(exhibit)
sidecar(exhibit).public!
end
|
#private?(exhibit) ⇒ Boolean
95
96
97
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 95
def private?(exhibit)
!public?(exhibit)
end
|
#public?(exhibit) ⇒ Boolean
99
100
101
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 99
def public?(exhibit)
sidecar(exhibit).public?
end
|
#reindex ⇒ Object
75
76
77
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 75
def reindex
end
|
#sidecar(exhibit) ⇒ Object
79
80
81
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 79
def sidecar(exhibit)
sidecars.find_or_initialize_by exhibit: exhibit
end
|
#to_solr ⇒ Object
83
84
85
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 83
def to_solr
{ self.class.unique_key.to_sym => id }.reverse_merge(sidecars.inject({}) { |a, e| a.merge(e.to_solr) }).merge(tags_to_solr)
end
|
#update(current_exhibit, new_attributes) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 55
def update(current_exhibit, new_attributes)
attributes = new_attributes.stringify_keys
custom_data = attributes.delete('sidecar')
tags = attributes.delete('exhibit_tag_list')
resource_attributes = attributes.delete('uploaded_resource')
sidecar(current_exhibit).update(custom_data) if custom_data
current_exhibit.tag(self, with: tags, on: :tags) if tags
update_exhibit_resource(resource_attributes) if uploaded_resource?
end
|
#update_exhibit_resource(resource_attributes) ⇒ Object
70
71
72
73
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 70
def update_exhibit_resource(resource_attributes)
return unless resource_attributes && resource_attributes['url']
uploaded_resource.update url: resource_attributes['url']
end
|
#uploaded_resource? ⇒ Boolean
103
104
105
106
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 103
def uploaded_resource?
self[self.class.resource_type_field].present? &&
self[self.class.resource_type_field].include?('spotlight/resources/uploads')
end
|