-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed that mash doesn't hash stuff consistently and thus makes it har…
…d to use mashed objects with set and such. (technomancy)
- Loading branch information
1 parent
de57b1c
commit 2da4913
Showing
2 changed files
with
17 additions
and
2 deletions.
There are no files selected for viewing
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
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
2da4913
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I did some digging and found out that it’s Ruby’s core Hash#hash that’s at fault; Mash only manifests this problem since it inherits from Hash.
The workaround to hash the inspect string works here, but unfortunately isn’t a good general-case fix because it honors insertion order, which should be irrelevant to the final hashed value.
2da4913
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also: I’m curious what advantage Mash provides over OpenStruct, since that’s included in the standard library. It wouldn’t fix the #hash problem unfortunately, but it’d be one fewer dependency.
2da4913
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started with openstruct and I think the problem was that a hash of hashes doesn’t allow dot notation. Does that make sense? I’m open to other solutions if you come up with something.
2da4913
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually using separate Twitter::Status classes made the most sense to me because it was most explicit. I suppose you’ve moved away from that because you’d rather let the API responses determine all the set of methods so you don’t have to update your code if the API changes?
2da4913
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct sir. I got tired of updating and pull in changes for every little tweak in the api.
2da4913
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s too bad you can’t lock to a specific version of the REST API and only upgrade when you need a new piece of functionality.
2da4913
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I would imagine eventually that twitter will no longer update the api so much. Right now it is still forming which makes changes more of an issue.