Sha256: 8b217e18b358eb2ff8c14411e29ec2590448873b8a99e53bec2292078752ace0

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

module Archangel
  ##
  # Site model
  #
  class Site < ApplicationRecord
    acts_as_paranoid

    mount_uploader :favicon, Archangel::FaviconUploader
    mount_uploader :logo, Archangel::LogoUploader

    validates :favicon, file_size: {
      less_than_or_equal_to: Archangel.config.favicon_maximum_file_size
    }
    validates :locale, presence: true, inclusion: { in: Archangel::LANGUAGES }
    validates :logo, file_size: {
      less_than_or_equal_to: Archangel.config.image_maximum_file_size
    }
    validates :name, presence: true
    validates :theme, presence: true,
                      inclusion: { in: Archangel.themes },
                      allow_blank: true

    has_many :assets
    has_many :collections
    has_many :pages
    has_many :templates
    has_many :users
    has_many :widgets

    has_many :entries, through: :collections

    ##
    # Current site
    #
    # @return [Object] first availabe site as current site
    #
    def self.current
      first_or_create do |site|
        site.name = "Archangel"
      end
    end

    ##
    # Liquid object for Site
    #
    # @return [Object] the Liquid object
    #
    def to_liquid
      Archangel::Liquid::Drops::SiteDrop.new(self)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
archangel-0.0.5 app/models/archangel/site.rb
archangel-0.0.4 app/models/archangel/site.rb
archangel-0.0.3 app/models/archangel/site.rb
archangel-0.0.2 app/models/archangel/site.rb