Created
November 14, 2013 03:54
-
-
Save joshuapinter/7461083 to your computer and use it in GitHub Desktop.
Simple String method to only symbolize with a given array of whitelist values.
This file contains hidden or 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 String | |
def symbolize_with_care *args | |
valid_values = args | |
valid_values.each do |v| | |
if v.to_s == self | |
return v | |
break | |
end | |
end | |
raise "No valid values to symbolize #{self}." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment