Skip to content
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

Remove Twingly::URL::Hasher #77

Open
jage opened this issue Jan 28, 2016 · 2 comments
Open

Remove Twingly::URL::Hasher #77

jage opened this issue Jan 28, 2016 · 2 comments

Comments

@jage
Copy link
Contributor

jage commented Jan 28, 2016

We had a discussion about the Twingly::URL::Hasher discussions today. What we want to do is to remove the helper functions:

  • Twingly::URL::Hasher.taskdb_hash(url)
  • Twingly::URL::Hasher.blogstream_hash(url)
  • Twingly::URL::Hasher.documentdb_hash(url)
  • Twingly::URL::Hasher.autopingdb_hash(url)

Since we only use the hash with Twingly::URL objects we should introduce these functions as instance methods to Twingly::URL instead. I would prefer if we allowed one method (documentdb_hash) to be the default go to hash algorithm and call it to_hash as well, in the long run we should avoid using different hash implementations.

@dentarg
Copy link
Collaborator

dentarg commented Apr 24, 2016

I would prefer if we allowed one method (documentdb_hash) to be the default go to hash algorithm and call it to_hash as well

Don't think to_hash is suitable name in Ruby land :-) Otherwise I'm not against the idea of a default hash

@walro
Copy link
Contributor

walro commented Apr 24, 2016

Since we only use the hash with Twingly::URL objects

Actually, we only use these with string objects. For instance: https://github.com/twingly/zambezi/blob/7f0a7a5cfdf074e495d54aeb387f79b0e0d2c7a5/lib/converter.rb#L85 (follow backwards to see original passed values).

I think we could stuff the methods into the utilities class instead, but other than that I don't mind how things currently look.

I don't mind the idea of putting the hasher methods on the URL objects, my only objection is that Zambezi would have to parse every string (i.e. convert to a Twingly::URL) before it can hash it, I know it's a slow process :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants