Sha256: db335a49cf80356d9ad5ca1dd23172d47de476af9040d00dfd44e790c9453154

Contents?: true

Size: 846 Bytes

Versions: 13

Compression:

Stored size: 846 Bytes

Contents

module Simplec
  class Subdomain < ApplicationRecord
    has_many :pages
    has_and_belongs_to_many :document_sets
    has_and_belongs_to_many :documents

    validates :name,
      presence: true,
      exclusion: { in: %w(admin) }
    validates :default_layout,
      inclusion: {in: :layouts, allow_blank: true}

    def layouts
      @layouts ||= Dir[Rails.root.join('app/views/layouts').to_s + "/*.html.*"].
        map{|n| File.basename(n).split('.', 2).first }.
        reject{|n| n =~ /\A_/ || n =~ /mailer/ || n =~ /application/ || n =~ /sessions/}. # TODO application and session should be removed and added to a config option
        sort
    end

    module Normalizers

      # Force lowercase name
      #
      def name=(val)
        super (val ? val.to_s.strip.downcase : val)
      end
    end
    prepend Normalizers
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
simplec-0.10.1 app/models/simplec/subdomain.rb
simplec-0.10.0 app/models/simplec/subdomain.rb
simplec-0.9.2 app/models/simplec/subdomain.rb
simplec-0.9.1 app/models/simplec/subdomain.rb
simplec-0.9.0 app/models/simplec/subdomain.rb
simplec-0.8.1 app/models/simplec/subdomain.rb
simplec-0.8.0 app/models/simplec/subdomain.rb
simplec-0.7.1 app/models/simplec/subdomain.rb
simplec-0.7.0 app/models/simplec/subdomain.rb
simplec-0.6.0 app/models/simplec/subdomain.rb
simplec-0.5.0 app/models/simplec/subdomain.rb
simplec-0.4.4 app/models/simplec/subdomain.rb
simplec-0.4.3 app/models/simplec/subdomain.rb