summaryrefslogtreecommitdiff
path: root/app/models/phone_number_range.rb
blob: 2fdd9b6afbfa5e9d616e63ca6a598c34881ecd9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class PhoneNumberRange < ActiveRecord::Base
  attr_accessible :name, :description

  has_many :phone_numbers, :as => :phone_numberable, :dependent => :destroy
  belongs_to :phone_number_rangeable, :polymorphic => true
  
  validates_presence_of :name
  validates_uniqueness_of :name, :scope => [:phone_number_rangeable_id, :phone_number_rangeable_type]
  validates_inclusion_of :name, :in => [INTERNAL_EXTENSIONS, DIRECT_INWARD_DIALING_NUMBERS, SERVICE_NUMBERS]
  validates_presence_of :phone_number_rangeable_id
  validates_presence_of :phone_number_rangeable
  
  def to_s
    name
  end
end