Module: Spotlight::SolrDocument

Extended by:
ActiveSupport::Concern
Includes:
Blacklight::SolrHelper, ActiveModelConcern, Finder
Defined in:
app/models/concerns/spotlight/solr_document.rb,
app/models/concerns/spotlight/solr_document/finder.rb

Defined Under Namespace

Modules: ActiveModelConcern, AtomicUpdates, ClassMethods, Finder, UploadedResource

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Finder

#blacklight_solr

Methods included from ActiveModelConcern

#destroyed?, #new_record?, #persisted?, #save, #to_key

Class Method Details

.solr_field_for_tagger(tagger) ⇒ Object



57
58
59
# File 'app/models/concerns/spotlight/solr_document.rb', line 57

def self.solr_field_for_tagger tagger
  ("#{Spotlight::Engine.config.solr_fields.prefix}#{tagger.class.model_name.param_key}_#{tagger.id}_tags" + Spotlight::Engine.config.solr_fields.string_suffix).to_sym
end

.visibility_field(exhibit) ⇒ Object



61
62
63
# File 'app/models/concerns/spotlight/solr_document.rb', line 61

def self.visibility_field exhibit
  ("#{Spotlight::Engine.config.solr_fields.prefix}#{exhibit.class.model_name.param_key}_#{exhibit.id}_public" + Spotlight::Engine.config.solr_fields.boolean_suffix).to_sym
end

Instance Method Details

#attribute_present?(*args) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
# File 'app/models/concerns/spotlight/solr_document.rb', line 87

def attribute_present? *args
  false
end

#make_private!(exhibit) ⇒ Object



69
70
71
# File 'app/models/concerns/spotlight/solr_document.rb', line 69

def make_private! exhibit
  sidecar(exhibit).private!
end

#make_public!(exhibit) ⇒ Object



65
66
67
# File 'app/models/concerns/spotlight/solr_document.rb', line 65

def make_public! exhibit
  sidecar(exhibit).public!
end

#private?(exhibit) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
# File 'app/models/concerns/spotlight/solr_document.rb', line 73

def private? exhibit
  !(public?(exhibit))
end

#public?(exhibit) ⇒ Boolean

Returns:

  • (Boolean)


77
78
79
# File 'app/models/concerns/spotlight/solr_document.rb', line 77

def public? exhibit
  sidecar(exhibit).public?
end

#reindexObject



45
46
47
# File 'app/models/concerns/spotlight/solr_document.rb', line 45

def reindex
  # no-op reindex implementation
end

#sidecar(exhibit) ⇒ Object



49
50
51
# File 'app/models/concerns/spotlight/solr_document.rb', line 49

def sidecar exhibit
  sidecars.find_or_initialize_by exhibit: exhibit
end

#to_solrObject



53
54
55
# File 'app/models/concerns/spotlight/solr_document.rb', line 53

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



32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/models/concerns/spotlight/solr_document.rb', line 32

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")
    # Note: this causes a save
    current_exhibit.tag(self, with: tags, on: :tags)
  end
end

#uploaded_resource?Boolean

Returns:

  • (Boolean)


81
82
83
84
85
# File 'app/models/concerns/spotlight/solr_document.rb', line 81

def uploaded_resource?
  self[Spotlight::Engine.config.full_image_field].present? &&
  self[:spotlight_resource_type_ssm].present? &&
  self[:spotlight_resource_type_ssm].include?("spotlight/resources/uploads")
end