Created
March 4, 2015 00:15
-
-
Save br3nt/cc0d9ecf41411f85b7c6 to your computer and use it in GitHub Desktop.
IndifferentString - like HashWithIndifferentAccess
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
class IndifferentString < String | |
def initialize(val) | |
# NOTE: would it be better to raise a TypeError if val isnt string or symbol? | |
# or is it okay to duck type here? | |
super(val.to_s) | |
end | |
def ==(other_object) | |
self.to_sym == other_object.to_sym | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment