Class: Spotlight::Resource

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
ActiveModel::Callbacks
Includes:
ActiveSupport::Benchmarkable, SolrDocument::AtomicUpdates
Defined in:
app/models/spotlight/resource.rb

Overview

Exhibit resources

Direct Known Subclasses

Spotlight::Resources::Upload

Instance Method Summary collapse

Methods included from SolrDocument::AtomicUpdates

#reindex

Instance Method Details

#becomes_providerObject



24
25
26
27
28
29
30
31
32
# File 'app/models/spotlight/resource.rb', line 24

def becomes_provider
  klass = Spotlight::ResourceProvider.for_resource(self)

  if klass
    self.becomes! klass
  else
    self
  end
end

#needs_provider?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'app/models/spotlight/resource.rb', line 34

def needs_provider?
  type.blank?
end

#reindex_laterObject

Enqueue an asynchronous reindexing job for this resource



48
49
50
# File 'app/models/spotlight/resource.rb', line 48

def reindex_later
  Spotlight::ReindexJob.perform_later(self)
end

#save_and_index(*args) ⇒ Object

Persist the record to the database, and trigger a reindex to solr

Parameters:

  • All (Hash)

    arguments will be passed through to ActiveRecord’s #save method



42
43
44
# File 'app/models/spotlight/resource.rb', line 42

def save_and_index(*args)
  save(*args) && reindex_later
end