Sha256: 73ed3aa9215e79aed25e1ac3ee22bfbc20e862b9d5da2680dc26c5207b179ff9

Contents?: true

Size: 1.11 KB

Versions: 15

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Maglev
  class Page < ApplicationRecord
    ## concerns ##
    include Maglev::Translatable
    include Maglev::SectionsConcern
    include Maglev::Page::PathConcern
    include Maglev::Page::SearchConcern

    ## translations ##
    translates :title, presence: true
    translates :sections
    translates :seo_title, :meta_description
    translates :og_title, :og_description, :og_image_url

    ## scopes ##
    scope :home, ->(locale = nil) { by_path('index', locale) }
    scope :visible, -> { where(visible: true) }
    scope :by_id_or_path, lambda { |id_or_path, locale = nil|
                            joins(:paths).where(id: id_or_path).or(core_by_path(id_or_path, locale))
                          }
    scope :by_path, ->(path, locale = nil) { core_by_path(path, locale).joins(:paths) }
    scope :core_by_path, lambda { |path, locale = nil|
                           where(paths: { locale: locale || Maglev::I18n.current_locale, value: path })
                         }

    ## methods ##

    def index?
      path == 'index'
    end

    def static?
      false
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
maglevcms-1.2.2 app/models/maglev/page.rb
maglevcms-1.2.1 app/models/maglev/page.rb
maglevcms-1.2.0 app/models/maglev/page.rb
maglevcms-1.1.7 app/models/maglev/page.rb
maglevcms-1.1.6 app/models/maglev/page.rb
maglevcms-1.1.5 app/models/maglev/page.rb
maglevcms-1.1.4 app/models/maglev/page.rb
maglevcms-1.1.3 app/models/maglev/page.rb
maglevcms-1.1.2 app/models/maglev/page.rb
maglevcms-1.1.1 app/models/maglev/page.rb
maglevcms-1.1.0 app/models/maglev/page.rb
maglevcms-1.0.0 app/models/maglev/page.rb
maglevcms-1.0.0.rc3 app/models/maglev/page.rb
maglevcms-1.0.0.rc2 app/models/maglev/page.rb
maglevcms-1.0.0.rc1 app/models/maglev/page.rb