Class: Spotlight::Exhibit

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Includes:
ExhibitAnalytics
Defined in:
app/models/spotlight/exhibit.rb

Overview

Spotlight exhibit

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ExhibitAnalytics

#analytics, #page_analytics

Class Method Details

.defaultObject

Find or create the default exhibit



57
58
59
60
61
# File 'app/models/spotlight/exhibit.rb', line 57

def self.default
  self.find_or_create_by!(default: true) do |e|
    e.title = 'Default exhibit'.freeze
  end
end

.default?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'app/models/spotlight/exhibit.rb', line 63

def self.default?
  where(default: true).any?
end

Instance Method Details

#browse_categories?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'app/models/spotlight/exhibit.rb', line 71

def browse_categories?
  searches.published.any?
end

#import(hash) ⇒ Object



79
80
81
82
# File 'app/models/spotlight/exhibit.rb', line 79

def import(hash)
  Spotlight::ExhibitExportSerializer.prepare(self).from_hash(hash)
  self
end

#main_about_pageObject



67
68
69
# File 'app/models/spotlight/exhibit.rb', line 67

def main_about_page
  @main_about_page ||= about_pages.published.first
end

#reindex_laterObject



88
89
90
# File 'app/models/spotlight/exhibit.rb', line 88

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

#searchable?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'app/models/spotlight/exhibit.rb', line 96

def searchable?
  blacklight_config.search_fields.any? { |_k, v| v.enabled && v.include_in_simple_select != false }
end

#solr_dataObject



84
85
86
# File 'app/models/spotlight/exhibit.rb', line 84

def solr_data
  { :"#{Spotlight::Engine.config.solr_fields.prefix}spotlight_exhibit_slug_#{slug}#{Spotlight::Engine.config.solr_fields.boolean_suffix}" => true }
end

#to_sObject



75
76
77
# File 'app/models/spotlight/exhibit.rb', line 75

def to_s
  title
end

#uploaded_resource_fieldsObject



92
93
94
# File 'app/models/spotlight/exhibit.rb', line 92

def uploaded_resource_fields
  Spotlight::Engine.config.upload_fields
end