Class: Atrium::Collection
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Atrium::Collection
- Defined in:
- app/models/atrium/collection.rb
Constant Summary collapse
- @@included_themes =
['default']
Class Method Summary collapse
Instance Method Summary collapse
- #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
83 84 85 86 87 88 89 |
# File 'app/models/atrium/collection.rb', line 83 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 local_themes = Dir.entries(File.join(Rails.root, 'app/views/layouts/atrium_themes')).reject {|f| f =~ /^\./} local_themes.collect!{|f| f.split('.').first} @@available_themes = @@included_themes + local_themes end |
Instance Method Details
#collection_items ⇒ Object
99 100 101 |
# File 'app/models/atrium/collection.rb', line 99 def collection_items read_attribute(:collection_items) || write_attribute(:collection_items, {}) end |
#display_title ⇒ Object
112 113 114 |
# File 'app/models/atrium/collection.rb', line 112 def display_title has_custom_title? ? title_markup.html_safe : "<h2>#{pretty_title}</h2>".html_safe end |
#exhibit_order ⇒ Object
69 70 71 72 73 |
# File 'app/models/atrium/collection.rb', line 69 def exhibit_order exhibit_order = {} exhibits.map{|exhibit| exhibit_order[exhibit[:id]] = exhibit.set_number } exhibit_order end |
#exhibit_order=(exhibit_order = {}) ⇒ Object
75 76 77 78 79 80 |
# File 'app/models/atrium/collection.rb', line 75 def exhibit_order=(exhibit_order = {}) valid_ids = exhibits.select(:id).map{|exhibit| exhibit[:id]} exhibit_order.each_pair do |id, order| Atrium::Exhibit.find(id).update_attributes!(:set_number => order) if valid_ids.include?(id.to_i) end end |
#pretty_title ⇒ Object
108 109 110 |
# File 'app/models/atrium/collection.rb', line 108 def pretty_title title.blank? ? 'Unnamed Collection' : title end |
#search_facet_names ⇒ Object
34 35 36 |
# File 'app/models/atrium/collection.rb', line 34 def search_facet_names search_facets.map{|facet| facet.name } end |
#search_facet_names=(collection_of_facet_names) ⇒ Object
38 39 40 41 42 |
# File 'app/models/atrium/collection.rb', line 38 def search_facet_names=(collection_of_facet_names) existing_facet_names = search_facets.map{|facet| facet.name } 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
104 105 106 |
# File 'app/models/atrium/collection.rb', line 104 def solr_doc_ids collection_items[:solr_doc_ids] unless collection_items.blank? end |
#theme_path ⇒ Object
91 92 93 |
# File 'app/models/atrium/collection.rb', line 91 def theme_path theme.blank? ? 'atrium_themes/default' : "atrium_themes/#{theme}" end |