Sha256: e6ad52061d89450f5f778a199edb934c241809720f9ddc8bc3161c4dabe1952a

Contents?: true

Size: 1.23 KB

Versions: 8

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module Maglev
  class Site < ApplicationRecord
    ## concerns ##
    include Maglev::Site::LocalesConcern
    include Maglev::SectionsConcern
    include Maglev::Translatable

    ## translations ##
    translates :sections

    ## validations ##
    validates :name, presence: true

    ## methods ##
    def api_attributes
      %i[id name]
    end

    def find_section(type)
      sections&.find { |section| section['type'] == type }
    end

    def translate_in(locale, source_locale)
      translate_attr_in(:sections, locale, source_locale)
    end
  end
end

# == Schema Information
#
# Table name: maglev_sites
#
#  id                    :bigint           not null, primary key
#  domain                :string
#  handle                :string
#  locales               :jsonb
#  lock_version          :integer
#  name                  :string
#  navigation            :jsonb
#  sections_translations :jsonb
#  siteable_type         :string
#  style                 :jsonb
#  created_at            :datetime         not null
#  updated_at            :datetime         not null
#  siteable_id           :bigint
#  theme_id              :string
#
# Indexes
#
#  index_maglev_sites_on_siteable  (siteable_type,siteable_id)
#

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
maglevcms-1.8.0 app/models/maglev/site.rb
maglevcms-1.7.3 app/models/maglev/site.rb
maglevcms-1.7.2 app/models/maglev/site.rb
maglevcms-1.7.1 app/models/maglev/site.rb
maglevcms-1.7.0 app/models/maglev/site.rb
maglevcms-1.6.1 app/models/maglev/site.rb
maglevcms-1.6.0 app/models/maglev/site.rb
maglevcms-1.5.1 app/models/maglev/site.rb