Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Adds custom phone number field for mongoid with proper formatting
branch: master

This branch is 1 commit ahead, 1 commit behind sarwagya:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.DS_Store
.gitignore
Gemfile
LICENCE.txt
README.rdoc
Rakefile
mongoid_phone_number.gemspec

README.rdoc

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

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

Something went wrong with that request. Please try again.