Module: Spotlight::SolrDocument
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/spotlight/solr_document.rb
Defined Under Namespace
Modules: AtomicUpdates, ClassMethods
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.solr_field_for_tagger(tagger) ⇒ Object
79
80
81
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 79
def self.solr_field_for_tagger tagger
:"#{tagger.class.model_name.param_key}_#{tagger.id}_tags_ssim"
end
|
.visibility_field(exhibit) ⇒ Object
83
84
85
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 83
def self.visibility_field exhibit
:"#{exhibit.class.model_name.param_key}_#{exhibit.id}_public_bsi"
end
|
Instance Method Details
#destroyed? ⇒ Boolean
63
64
65
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 63
def destroyed?
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
|
#new_record? ⇒ Boolean
67
68
69
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 67
def new_record?
!persisted?
end
|
#persisted? ⇒ Boolean
59
60
61
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 59
def persisted?
true
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
46
47
48
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 46
def reindex
end
|
#save ⇒ Object
50
51
52
53
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 50
def save
save_owned_tags
reindex
end
|
#sidecar(exhibit) ⇒ Object
71
72
73
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 71
def sidecar exhibit
sidecars.first_or_initialize(exhibit: exhibit)
end
|
#to_key ⇒ Object
55
56
57
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 55
def to_key
[id]
end
|
#to_solr ⇒ Object
75
76
77
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 75
def to_solr
{ id: id }.reverse_merge(sidecars.inject({}) { |result, sidecar| result.merge(sidecar.to_solr) }).merge(tags_to_solr)
end
|
#update(current_exhibit, new_attributes) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/models/concerns/spotlight/solr_document.rb', line 33
def update current_exhibit, new_attributes
attributes = new_attributes.stringify_keys
if custom_data = attributes.delete("sidecar")
sidecar(current_exhibit).update(custom_data)
end
if tags = attributes.delete("exhibit_tag_list")
current_exhibit.tag(self, with: tags, on: :tags)
end
end
|