Created
August 15, 2015 00:43
-
-
Save narma/e87b76a51e1610350c4a to your computer and use it in GitHub Desktop.
ruby keywordize keys
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 Hash | |
| def keywordize! | |
| self.keys.each do |k| | |
| if k.class == String | |
| self[k.to_sym] = self[k] | |
| self.delete(k) | |
| end | |
| end | |
| self | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment