Class: Spotlight::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spotlight::Page
show all
- Extended by:
- FriendlyId
- Defined in:
- app/models/spotlight/page.rb
Overview
Constant Summary
collapse
- MAX_PAGES =
50
Instance Method Summary
collapse
Instance Method Details
#about_page? ⇒ Boolean
73
74
75
|
# File 'app/models/spotlight/page.rb', line 73
def about_page?
is_a? AboutPage
end
|
#content=(content) ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'app/models/spotlight/page.rb', line 36
def content=(content)
if content.is_a? Array
super content.to_json
else
super
end
content_changed!
end
|
#content? ⇒ Boolean
Also known as:
has_content?
45
46
47
|
# File 'app/models/spotlight/page.rb', line 45
def content?
self[:content].present? && content.present?
end
|
#content_changed! ⇒ Object
32
33
34
|
# File 'app/models/spotlight/page.rb', line 32
def content_changed!
@content = nil
end
|
50
51
52
|
# File 'app/models/spotlight/page.rb', line 50
def
true
end
|
#feature_page? ⇒ Boolean
69
70
71
|
# File 'app/models/spotlight/page.rb', line 69
def feature_page?
is_a? FeaturePage
end
|
#featured_image ⇒ Object
54
55
56
|
# File 'app/models/spotlight/page.rb', line 54
def featured_image
nil
end
|
#lock!(user) ⇒ Object
93
94
95
|
# File 'app/models/spotlight/page.rb', line 93
def lock!(user)
create_lock(by: user).tap(&:current_session!) unless lock.present?
end
|
#should_display_title? ⇒ Boolean
89
90
91
|
# File 'app/models/spotlight/page.rb', line 89
def should_display_title?
title.present?
end
|
#should_generate_new_friendly_id? ⇒ Boolean
85
86
87
|
# File 'app/models/spotlight/page.rb', line 85
def should_generate_new_friendly_id?
super || (title_changed? && persisted?)
end
|
#thumbnail_image_url ⇒ Object
58
59
60
61
|
# File 'app/models/spotlight/page.rb', line 58
def thumbnail_image_url
return unless thumbnail && thumbnail.iiif_url
thumbnail.iiif_url
end
|
#to_partial_path ⇒ Object
explicitly set the partial path so that we don’t have to duplicate view logic.
65
66
67
|
# File 'app/models/spotlight/page.rb', line 65
def to_partial_path
'spotlight/pages/page'
end
|
#top_level_page? ⇒ Boolean
77
78
79
|
# File 'app/models/spotlight/page.rb', line 77
def top_level_page?
try(:parent_page).blank?
end
|
#top_level_page_or_self ⇒ Object
81
82
83
|
# File 'app/models/spotlight/page.rb', line 81
def top_level_page_or_self
parent_page || self
end
|