Skip to content

Adds custom phone number field for mongoid with proper formatting

License

Notifications You must be signed in to change notification settings

bdimcheff/mongoid_phone_number

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongoid_phone_number

This gem creates a new field type ‘Mongoid::PhoneNumber’ for mongoid. It discards all non-numeric parts of the phone number while storing in database and prints out the well formatted phone number when retrieved. Currently it supports only north-american phone number format.

Installation

gem install mongoid_phone_number

Examples

Define

class User
  include Mongoid::Document

  field :home_phone, :type => Mongoid::PhoneNumber

end

Set

user.home_phone = '1 (809) (123) (1234)'

user.home_phone = '18091231234'

user.home_phone = '+1-809-123-1234'

...

Get

user.home_phone # "1-809-123-1234"

user.home_phone = '809 123 1234'
user.home_phone # '809-123-1234'

Copyright © 2011 Sarwagya Pandey. See LICENSE.txt for further details.

About

Adds custom phone number field for mongoid with proper formatting

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Ruby 100.0%