Class: Spotlight::Resource

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

Overview

Exhibit resources

Instance Method Summary collapse

Instance Method Details

#document_modelObject



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

def document_model
  exhibit.blacklight_config.document_model if exhibit
end

#enqueued_atObject



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

def enqueued_at
  cast_to_date_time(super)
end

#enqueued_at?Boolean

Returns:

  • (Boolean)


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

def enqueued_at?
  enqueued_at.present?
end

#last_indexed_finishedObject



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

def last_indexed_finished
  cast_to_date_time(super)
end

#reindex_laterObject

Enqueue an asynchronous reindexing job for this resource



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

def reindex_later
  waiting!
  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



37
38
39
# File 'app/models/spotlight/resource.rb', line 37

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

#waiting!Object



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

def waiting!
  update(enqueued_at: Time.zone.now)
  super
end