Class: Spotlight::Page

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

Direct Known Subclasses

AboutPage, FeaturePage, HomePage

Constant Summary collapse

MAX_PAGES =
50

Instance Method Summary collapse

Instance Method Details

#about_page?Boolean

Returns:

  • (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

#display_sidebar?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'app/models/spotlight/page.rb', line 45

def display_sidebar?
  true
end

#feature_page?Boolean

Returns:

  • (Boolean)


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

def feature_page?
  is_a? FeaturePage
end


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

def featured_image
  nil
end

#has_content?Boolean

Returns:

  • (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

Returns:

  • (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

Returns:

  • (Boolean)


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

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.



55
56
57
# File 'app/models/spotlight/page.rb', line 55

def to_partial_path
  "spotlight/pages/page"
end

#top_level_page?Boolean

Returns:

  • (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_selfObject



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

def top_level_page_or_self
  parent_page || self
end