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
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/spud_page.rb', line 35 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_processed ⇒ Object
24 25 26 |
# File 'app/models/spud_page.rb', line 24 def full_content_processed spud_page_partials.collect(&:content_processed).join(' ') end |
#is_private? ⇒ Boolean
51 52 53 |
# File 'app/models/spud_page.rb', line 51 def is_private? return visibility == 1 end |
#to_liquid ⇒ Object
28 29 30 |
# File 'app/models/spud_page.rb', line 28 def to_liquid return { 'name' => name, 'url_name' => url_name } end |