Class: Spotlight::Resource
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spotlight::Resource
- Extended by:
- ActiveModel::Callbacks
- Includes:
- ActiveSupport::Benchmarkable, SolrDocument::AtomicUpdates
- Defined in:
- app/models/spotlight/resource.rb
Overview
Exhibit resources
Direct Known Subclasses
Instance Method Summary collapse
- #becomes_provider ⇒ Object
- #needs_provider? ⇒ Boolean
-
#reindex_later ⇒ Object
Enqueue an asynchronous reindexing job for this resource.
-
#save_and_index(*args) ⇒ Object
Persist the record to the database, and trigger a reindex to solr.
Methods included from SolrDocument::AtomicUpdates
Instance Method Details
#becomes_provider ⇒ Object
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
34 35 36 |
# File 'app/models/spotlight/resource.rb', line 34 def needs_provider? type.blank? end |
#reindex_later ⇒ Object
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
42 43 44 |
# File 'app/models/spotlight/resource.rb', line 42 def save_and_index(*args) save(*args) && reindex_later end |