Sha256: 72435f07c3dfae09f3685c6b0709c34bebaf62615ba793fc3c4c9bfb71a1c898

Contents?: true

Size: 708 Bytes

Versions: 7

Compression:

Stored size: 708 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/}.
				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

7 entries across 7 versions & 1 rubygems

Version Path
simplec-0.4.2 app/models/simplec/subdomain.rb
simplec-0.4.1 app/models/simplec/subdomain.rb
simplec-0.4.0 app/models/simplec/subdomain.rb
simplec-0.3.0 app/models/simplec/subdomain.rb
simplec-0.2.0 app/models/simplec/subdomain.rb
simplec-0.1.2 app/models/simplec/subdomain.rb
simplec-0.1.0 app/models/simplec/subdomain.rb