Class: SpudPage

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
CmsDeprecatedMultisite, TbRedirects::HasRedirects
Defined in:
app/models/spud_page.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CmsDeprecatedMultisite

#site_id, #site_id=

Class Method Details

.find_ignoring_case(url_name) ⇒ Object



63
64
65
# File 'app/models/spud_page.rb', line 63

def self.find_ignoring_case(url_name)
  find_by(arel_table[:url_name].matches(url_name))
end

.options_tree_for_page(config = {}) ⇒ Object

Returns an array of pages in order of heirarchy :fitler Filters out a page by ID, and all of its children

:value Pick an attribute to be used in the value field, defaults to ID


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/models/spud_page.rb', line 43

def self.options_tree_for_page(config = {})
  collection = config[:collection] || all.group_by(&:spud_page_id)
  level = config[:level] || 0
  parent_id = config[:parent_id] || nil
  filter = config[:filter] || nil
  value = config[:value] || :id
  list = []
  collection[parent_id]&.each do |c|
    if filter.blank? || c.id != filter.id
      list << [Array.new(level) { '- ' }.join('') + c.name, c[value]]
      list += options_tree_for_page(collection: collection, parent_id: c.id, level: level + 1, filter: filter)
    end
  end
  return list
end

Instance Method Details

#full_contentObject



36
37
38
# File 'app/models/spud_page.rb', line 36

def full_content
  spud_page_partials.collect(&:content).join(' ')
end

#full_content_processedObject



31
32
33
34
# File 'app/models/spud_page.rb', line 31

def full_content_processed
  ActiveSupport::Deprecation.warn('#full_content_processed is deprecated; use #full_content instead.')
  spud_page_partials.collect(&:content_processed).join(' ')
end

#is_private?Boolean

Returns:

  • (Boolean)


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

def is_private?
  return visibility == 1
end