Class: Spotlight::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spotlight::Page
show all
- Extended by:
- FriendlyId
- Defined in:
- app/models/spotlight/page.rb
Constant Summary
collapse
- MAX_PAGES =
50
Instance Method Summary
collapse
Instance Method Details
#about_page? ⇒ Boolean
63
64
65
|
# File 'app/models/spotlight/page.rb', line 63
def about_page?
is_a? AboutPage
end
|
#content=(content) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'app/models/spotlight/page.rb', line 32
def content= content
if content.is_a? Array
super content.to_json
else
super
end
content_changed!
end
|
#content_changed! ⇒ Object
28
29
30
|
# File 'app/models/spotlight/page.rb', line 28
def content_changed!
@content = nil
end
|
45
46
47
|
# File 'app/models/spotlight/page.rb', line 45
def
true
end
|
#feature_page? ⇒ Boolean
59
60
61
|
# File 'app/models/spotlight/page.rb', line 59
def feature_page?
is_a? FeaturePage
end
|
#featured_image ⇒ Object
49
50
51
|
# File 'app/models/spotlight/page.rb', line 49
def featured_image
nil
end
|
#has_content? ⇒ Boolean
41
42
43
|
# File 'app/models/spotlight/page.rb', line 41
def has_content?
read_attribute(:content).present? and content.present?
end
|
#lock!(user) ⇒ Object
83
84
85
86
87
88
|
# File 'app/models/spotlight/page.rb', line 83
def lock! user
unless lock.present?
create_lock(by: user)
lock.current_session!
end
end
|
#should_display_title? ⇒ Boolean
79
80
81
|
# File 'app/models/spotlight/page.rb', line 79
def should_display_title?
title.present?
end
|
#should_generate_new_friendly_id? ⇒ Boolean
75
76
77
|
# File 'app/models/spotlight/page.rb', line 75
def should_generate_new_friendly_id?
title_changed?
end
|
#to_partial_path ⇒ Object
explicitly set the partial path so that we don’t have to duplicate view logic.
55
56
57
|
# File 'app/models/spotlight/page.rb', line 55
def to_partial_path
"spotlight/pages/page"
end
|
#top_level_page? ⇒ Boolean
67
68
69
|
# File 'app/models/spotlight/page.rb', line 67
def top_level_page?
try(:parent_page).blank?
end
|
#top_level_page_or_self ⇒ Object
71
72
73
|
# File 'app/models/spotlight/page.rb', line 71
def top_level_page_or_self
parent_page || self
end
|