WIP: Introduce hashie to simplify object wrappers.#29
WIP: Introduce hashie to simplify object wrappers.#29
Conversation
|
@liquid Yeah, figured I'd rather consult others on this. Hmm alright, my idea was also to just wrap the Main issue I see with all of this is that there's no clear documentation about all of the available fields MPD will return for songs. In general from my experience that's |
|
Do you really need to simplify? has it got so out of hand that it needs this change? It's seem quite a simple class at the moment, and not messy. Personally, I'd much rather see |
|
I too think Hashie is unnecessary for this. You could do something like this (See Dmitry Polushkin's answer): https://stackoverflow.com/questions/2240535/how-do-i-use-hash-keys-as-methods-on-a-class I have an example branch here: https://github.com/mikerodrigues/ruby-mpd/tree/mrod-obj-rewrite **It does seem to always write the first value in the |
|
@mikerodrigues I do agree that Hashie is a bit of an overkill, your approach looks fine. I'd prefer to not directly subclass Hash though. We could also use something like |
|
At the very least, we should also be defining |
Still messing around with this, I was never satisfied with how the original was implemented, but I didn't want to introduce another dependency back then.
The ideal way probably is to use
Hashie::Dashand specify the allowed keys, probably do so dynamically (allowed keys arempd.typesand:file).