Sha256: 6d18064b019f2a56798764099b94fc3b15a768c4fbf7619d4e7b71ba4e442ac7
Contents?: true
Size: 901 Bytes
Versions: 4
Compression:
Stored size: 901 Bytes
Contents
class PhoneNumber < ActiveRecord::Base # Access restrictions attr_accessible :phone_number_type, :number # Vcard association belongs_to :vcard, :inverse_of => :contacts belongs_to :object, :polymorphic => true # Validation validates_presence_of :number # phone number types scope :by_type, lambda {|value| where(:phone_number_type => value)} scope :phone, by_type('phone') scope :fax, by_type('fax') scope :mobile, by_type('mobile') scope :email, by_type('email') def label case phone_number_type when 'phone' "Tel:" when 'fax' "Fax:" when 'mobile' "Mob:" when 'email' "Mail:" else phone_number_type end end # String def to_s(separator = " ", format = :default) case format when :label return [label, number].compact.join(separator) else return number end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
has_vcards-0.20.3 | app/models/phone_number.rb |
has_vcards-0.20.2 | app/models/phone_number.rb |
has_vcards-0.20.1 | app/models/phone_number.rb |
has_vcards-0.20.0 | app/models/phone_number.rb |