Class: SpudPage
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SpudPage
- Includes:
- CmsDeprecatedMultisite, TbRedirects::HasRedirects
- Defined in:
- app/models/spud_page.rb
Class Method Summary collapse
-
.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.
Instance Method Summary collapse
Methods included from CmsDeprecatedMultisite
Class Method Details
.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
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/spud_page.rb', line 42 def self.(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 += (collection: collection, parent_id: c.id, level: level + 1, filter: filter) end end return list end |
Instance Method Details
#full_content ⇒ Object
35 36 37 |
# File 'app/models/spud_page.rb', line 35 def full_content spud_page_partials.collect(&:content).join(' ') end |
#full_content_processed ⇒ Object
30 31 32 33 |
# File 'app/models/spud_page.rb', line 30 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
58 59 60 |
# File 'app/models/spud_page.rb', line 58 def is_private? return visibility == 1 end |