Class: Atrium::Collection
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Atrium::Collection
- Extended by:
- FriendlyId
- Includes:
- IsShowcasedMixin, QueryParamMixin
- Defined in:
- app/models/atrium/collection.rb
Overview
application and other collections.
Constant Summary collapse
- @@included_themes =
['Default']
Class Method Summary collapse
Instance Method Summary collapse
- #collection ⇒ Object
- #collection_items ⇒ Object
- #display_title ⇒ Object
- #exhibit_order ⇒ Object
- #exhibit_order=(exhibit_order = {}) ⇒ Object
- #pretty_title ⇒ Object
- #search_facet_names ⇒ Object
- #search_facet_names=(collection_of_facet_names) ⇒ Object
- #solr_doc_ids ⇒ Object
- #theme_path ⇒ Object
Class Method Details
.available_themes ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'app/models/atrium/collection.rb', line 104 def self.available_themes return @@available_themes if defined? @@available_themes # NOTE: theme filenames should conform to rails expectations and only use # periods to delimit file extensions begin local_themes = Dir.entries( Rails.root.join('app/views/layouts/atrium/themes').to_s ).reject {|f| f =~ /^[\._]/} local_themes.collect!{|f| f.split('.').first.titleize} @@available_themes = @@included_themes + local_themes rescue Errno::ENOENT @@included_themes end end |
Instance Method Details
#collection ⇒ Object
131 132 133 |
# File 'app/models/atrium/collection.rb', line 131 def collection self end |
#collection_items ⇒ Object
127 128 129 |
# File 'app/models/atrium/collection.rb', line 127 def collection_items read_attribute(:collection_items) || write_attribute(:collection_items, {}) end |
#display_title ⇒ Object
143 144 145 146 147 148 149 |
# File 'app/models/atrium/collection.rb', line 143 def display_title if has_custom_title? title_markup.html_safe else "<h2>#{pretty_title}</h2>".html_safe end end |
#exhibit_order ⇒ Object
88 89 90 91 92 |
# File 'app/models/atrium/collection.rb', line 88 def exhibit_order exhibit_order = {} exhibits.map{|exhibit| exhibit_order[exhibit[:id]] = exhibit.set_number } exhibit_order end |
#exhibit_order=(exhibit_order = {}) ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'app/models/atrium/collection.rb', line 94 def exhibit_order=(exhibit_order = {}) valid_ids = exhibits.select(:id).map{|exhibit| exhibit[:id]} exhibit_order.each_pair do |id, order| if valid_ids.include?(id.to_i) Atrium::Exhibit.find(id).update_attributes!(set_number: order) end end end |
#pretty_title ⇒ Object
139 140 141 |
# File 'app/models/atrium/collection.rb', line 139 def pretty_title title.blank? ? 'Unnamed Collection' : title end |
#search_facet_names ⇒ Object
50 51 52 |
# File 'app/models/atrium/collection.rb', line 50 def search_facet_names search_facets.pluck(:name) end |
#search_facet_names=(collection_of_facet_names) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'app/models/atrium/collection.rb', line 55 def search_facet_names=(collection_of_facet_names) existing_facet_names = search_facet_names add_collection_of_facets_by_name( collection_of_facet_names - existing_facet_names ) remove_collection_of_facets_by_name( existing_facet_names - collection_of_facet_names ) end |
#solr_doc_ids ⇒ Object
135 136 137 |
# File 'app/models/atrium/collection.rb', line 135 def solr_doc_ids collection_items[:solr_doc_ids] unless collection_items.blank? end |
#theme_path ⇒ Object
120 121 122 |
# File 'app/models/atrium/collection.rb', line 120 def theme_path theme.blank? ? 'atrium/themes/default' : "atrium/themes/#{theme.downcase}" end |