Created
July 24, 2012 22:11
-
-
Save xaviervia/3173016 to your computer and use it in GitHub Desktop.
Dictionary class based on SymbolTable
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
# This class has been implemented into a gem rebuilding SymbolTable from the ground. It's called "SymbolMatrix" | |
# http://github.com/Fetcher/symbolmatrix | |
# Stupid but really useful class: | |
# Inherits from SymbolTable (https://github.com/mjijackson/symboltable), but when it is initialized | |
# it simply... well, recursively converts all Hashes into dictionaries | |
class Dictionary < SymbolTable | |
def initialize *args | |
super *args | |
_symbolize! | |
end | |
private | |
def _symbolize! | |
each_key do |key| | |
if self[key].instance_of? Hash | |
self[key] = Dictionary.new self[key] | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment