Class: Spotlight::Exhibit
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spotlight::Exhibit
- Extended by:
- FriendlyId
- Defined in:
- app/models/spotlight/exhibit.rb
Class Method Summary collapse
-
.default ⇒ Object
Find or create the default exhibit.
Instance Method Summary collapse
- #analytics(start_date = 1.month, path = nil) ⇒ Object
- #appearance ⇒ Object
- #has_browse_categories? ⇒ Boolean
- #import(hash) ⇒ Object
- #main_about_page ⇒ Object
- #page_analytics(start_date = 1.month, path = nil) ⇒ Object
- #reindex_later ⇒ Object
- #solr_data ⇒ Object
- #to_s ⇒ Object
- #uploaded_resource_fields ⇒ Object
Class Method Details
.default ⇒ Object
Find or create the default exhibit
70 71 72 73 74 |
# File 'app/models/spotlight/exhibit.rb', line 70 def self.default self.find_or_create_by!(default: true) do |e| e.title = 'Default exhibit'.freeze end end |
Instance Method Details
#analytics(start_date = 1.month, path = nil) ⇒ Object
97 98 99 100 101 102 103 |
# File 'app/models/spotlight/exhibit.rb', line 97 def analytics start_date = 1.month, path = nil return OpenStruct.new unless analytics_provider and analytics_provider.enabled? @analytics ||= {} @analytics[start_date] ||= begin analytics_provider.exhibit_data(path || self, start_date: start_date.ago) end end |
#appearance ⇒ Object
93 94 95 |
# File 'app/models/spotlight/exhibit.rb', line 93 def appearance Spotlight::Appearance.new(blacklight_configuration) end |
#has_browse_categories? ⇒ Boolean
76 77 78 |
# File 'app/models/spotlight/exhibit.rb', line 76 def has_browse_categories? searches.published.any? end |
#import(hash) ⇒ Object
84 85 86 87 |
# File 'app/models/spotlight/exhibit.rb', line 84 def import hash Spotlight::ExhibitExportSerializer.prepare(self).from_hash(hash) self end |
#main_about_page ⇒ Object
65 66 67 |
# File 'app/models/spotlight/exhibit.rb', line 65 def main_about_page @main_about_page ||= about_pages.published.first end |
#page_analytics(start_date = 1.month, path = nil) ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'app/models/spotlight/exhibit.rb', line 105 def page_analytics start_date = 1.month, path = nil return [] unless analytics_provider and analytics_provider.enabled? @page_analytics ||= {} @page_analytics[start_date] ||= begin analytics_provider.page_data(path || self, start_date: start_date.ago) end end |
#reindex_later ⇒ Object
114 115 116 |
# File 'app/models/spotlight/exhibit.rb', line 114 def reindex_later Spotlight::ReindexJob.perform_later(self) end |
#solr_data ⇒ Object
89 90 91 |
# File 'app/models/spotlight/exhibit.rb', line 89 def solr_data { :"#{Spotlight::Engine.config.solr_fields.prefix}spotlight_exhibit_slug_#{slug}#{Spotlight::Engine.config.solr_fields.boolean_suffix}" => true } end |
#to_s ⇒ Object
80 81 82 |
# File 'app/models/spotlight/exhibit.rb', line 80 def to_s title end |