On Monday, February 17, 2014 2:16:53 AM UTC-8, Jamie Hodge wrote:
>
> Thank you Jeremy.
>
> I currently have this, which appears to work:
>
> def etag
> digest(_models.map(&:id).zip(_models.map(&:lock_version)).join)
> end
>
> def last_modified
> _models.map(&:updated_at).max
> end
>
> private
>
> def digest(string)
> Digest::SHA1.hexdigest(string)
> end
>
> def _models
> [
> collection,
> *collection.items,
> *collection.resources,
> *collection.resources.compact.map(&:original),
> *collection.resources.map(&:original).compact.map(&:proxies)
> ].compact.uniq
> end
>
Assuming you are using integer lock versions and primary keys, I think this
may still have an issue. It appears etag for the following two collections
would match (hard to be sure without seeing other related code):
[{id: 1, lock_version: 1, items: [{id: 1, lock_version: 1}], resources:
[]}]
[{id: 1, lock_version: 1, items: [], resources: [{id: 1, lock_version:
1}]}]
I think a simple fix would be to put a string between the different types
of objects you are dealing with.
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.