-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected []
behavior compared to other access patterns
#25
Comments
Could you expand on this a little? Fittings could return a (My personal vote would be for deprecating Fittings, which is more trouble than it's worth, but I understand that's another question.) |
@mboeh Ah, I was not familiar with that gem. Looks like |
It does look like there's functionality similar to |
I think that would be the least surprising solution. In any of these cases, we'll probably need to make it a new major version, though, in case anybody has code out there assuming that these methods return regular |
For top level keys you can use symbols, strings, or dot notation:
For nested keys can use symbols-in-brackets, but not strings-in-brackets
If you call the top level key like a method, you can use symbols or strings as the argument
You cannot call nested keys like methods
The "gotcha" here is using brackets with symbols, which could surprisingly not return a value. There are a few ways to address this inconsistency, but given the existing functionality that already works with both string and symbol, I'd suggest we recursively modify the Setting object so that all
[]
methods behave the same.[sym|string]
access equallySuggestion 2 is the most symmetrical, but also will require more monkey patching of Ruby core functionality. I'm leaning toward suggestion 1.Suggestions 2 could be done by wrapping each key recursively with
Hashie::Mash
, and might be the easiest.Once we have agreement on the approach I can work on a fix.
The text was updated successfully, but these errors were encountered: