Class: Spotlight::Page

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Defined in:
app/models/spotlight/page.rb

Overview

Base page class. See AboutPage, FeaturePage, HomePage

Direct Known Subclasses

AboutPage, FeaturePage, HomePage

Constant Summary collapse

MAX_PAGES =
50

Instance Method Summary collapse

Instance Method Details

#about_page?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'app/models/spotlight/page.rb', line 66

def about_page?
  is_a? AboutPage
end

#content=(content) ⇒ Object



34
35
36
37
38
39
40
41
# File 'app/models/spotlight/page.rb', line 34

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?

Returns:

  • (Boolean)


43
44
45
# File 'app/models/spotlight/page.rb', line 43

def content?
  self[:content].present? && content.present?
end

#content_changed!Object



30
31
32
# File 'app/models/spotlight/page.rb', line 30

def content_changed!
  @content = nil
end

#display_sidebar?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'app/models/spotlight/page.rb', line 48

def display_sidebar?
  true
end

#feature_page?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'app/models/spotlight/page.rb', line 62

def feature_page?
  is_a? FeaturePage
end


52
53
54
# File 'app/models/spotlight/page.rb', line 52

def featured_image
  nil
end

#lock!(user) ⇒ Object



86
87
88
# File 'app/models/spotlight/page.rb', line 86

def lock!(user)
  create_lock(by: user).tap(&:current_session!) unless lock.present?
end

#should_display_title?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'app/models/spotlight/page.rb', line 82

def should_display_title?
  title.present?
end

#should_generate_new_friendly_id?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'app/models/spotlight/page.rb', line 78

def should_generate_new_friendly_id?
  title_changed?
end

#to_partial_pathObject

explicitly set the partial path so that we don’t have to duplicate view logic.



58
59
60
# File 'app/models/spotlight/page.rb', line 58

def to_partial_path
  'spotlight/pages/page'
end

#top_level_page?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'app/models/spotlight/page.rb', line 70

def top_level_page?
  try(:parent_page).blank?
end

#top_level_page_or_selfObject



74
75
76
# File 'app/models/spotlight/page.rb', line 74

def top_level_page_or_self
  parent_page || self
end