Created
January 8, 2009 21:41
-
-
Save trak3r/44901 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
def has_role?(role) | |
# if list isn't already assigned to something, create an array of the names of my roles | |
list ||= self.roles.map(&:name) | |
# if list includes the string representation of the passed-in role [assumed to be the name] or if the list includes the string 'admin' [assumed to be the administrative role] return true | |
list.include?(role.to_s) || list.include?('admin') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment