Skip to content

Instantly share code, notes, and snippets.

@br3nt
Created March 4, 2015 00:15
Show Gist options
  • Save br3nt/cc0d9ecf41411f85b7c6 to your computer and use it in GitHub Desktop.
Save br3nt/cc0d9ecf41411f85b7c6 to your computer and use it in GitHub Desktop.
IndifferentString - like HashWithIndifferentAccess
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