Skip to content

Instantly share code, notes, and snippets.

@cassiomarques
Created November 13, 2010 03:36
Show Gist options
  • Save cassiomarques/675056 to your computer and use it in GitHub Desktop.
Save cassiomarques/675056 to your computer and use it in GitHub Desktop.
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