Created
October 11, 2011 17:58
-
-
Save jesscanady/1278850 to your computer and use it in GitHub Desktop.
Completely untested legacy bitfield-based role system fixer.
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
alias_attribute :administrator :IsAdministrator | |
alias_attribute :consumer :IsConsumer | |
# etc... | |
# now you can do checks like: | |
if @user.administrator? | |
# and if you need .role: | |
def role | |
case self | |
when administrator? | |
"administrator" | |
when consumer? | |
"consumer" | |
# etc... | |
end | |
end | |
n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment