In Sinatra, I could test for some_object.class.name == “Hash”. Now, after a submit, I have to test for that, plus == “ActiveSupport::HashWithIndifferentAccess”, for my code to work. Why is that, and do I have to update all the places where that comparison happens, or is there an easier way? thanks
In Sinatra, I could test for some_object.class.name == Hash. Now, after a submit, I
Share
From the docs on ActiveSupport::HashWithIndifferentAccess:
So, it’s a class that inherits from Hash to allow you to pass a symbol or a string as the key and return the same value for either.
To fix (and clean up) your tests, you could just use the following:
This will return true if it’s a Hash or a descendant of Hash.