Encapsulates functionality for storing an unformatted SSN but formatting the SSN on print.
-
Store a SSN unformatted in a database field with auto formatting when using.
-
SocialSecurityNumber class to use for formatting SSNs.
-
active_record >= 2.3
gem sources -a http://gemcutter.org sudo gem install ssn
Add to environment file:
gem 'ssn', '~>1.0.0'
Run:
bundle:install
Add to environment file:
config.gem 'ssn', :version => '~>1.0.0', :source => 'http://gemcutter.org'
Run:
sudo rake:gems:install
Add a raw_ssn that is at least 9 in length to the database table of the model you desire to track a SSN on.
Specify usage in your model:
class Person has_ssn :ssn ... end
Use the field:
person = Peson.new :ssn => '123456789' person.ssn # => 123-45-6789 person.ssn = '123-45-6789' person.ssn # => 123-45-6789
ssn = Ssn::SocialSecurityNumber.new( '123456789' ) ssn.raw # => 123456789 ssn.formatted # => 123-45-6789
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
Copyright © 2009 C. Jason Harrelson (midas)
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.