class Period < ApplicationRecord
  include Base::Period

  associations_for legacy: true do |a|
    a.belongs_to :school
  end

  has_many :class_periods, inverse_of: :period, dependent: :destroy
  has_many :classrooms, through: :class_periods

  associations_for namespace: 'EdFi' do |a|
    a.has_one :id, as: :associated, inverse_of: :associated, dependent: :destroy
  end

  validates :name, length: { maximum: 32 }
  validates :code, length: { maximum: 5 }
  validates :start_time, :stop_time, :name, :code, :order, presence: true
end
