Created
November 13, 2010 03:36
-
-
Save cassiomarques/675056 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ContactType < EnumerateIt::Base | |
associate_values( | |
:email => 1, | |
:sms => 2, | |
:phone => 3, | |
:smoke_signal => 4 | |
) | |
end | |
person = Person.new | |
person.contact_types = [1, 2, 4] | |
# | 1 | 2 | 3 | 4 | | |
# | 1 | 1 | 0 | 1 | | |
# | |
# 1101(2) ==> 13(10) ==> record 13 to the database | |
# | |
# ... and convert back from 13(10) to binary to get the values back. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment