You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
I'll have a look at this later, but to me, it seems logical that the following behaviour should not exhibit:
In process A:
@resource=Model.get!(1)@resource.destroy
In process B, simultaneously (or in the same process without the identity map):
@resource=Model.get!(1)# process A deletes the resource around about herep@resource.reload.destroyed?#=> false
To me, since we have a persisted state that indicates the resource is saved, yet we've failed to find the resource when doing a reload (note no exception is thrown), the resource should be flagged as destroyed.
This crops up in rails specs trying to assert that a record has been destroyed by a controller (in a semantic way).
The text was updated successfully, but these errors were encountered:
Awesome, thanks. I spent an entire day working on this last week but wasn't able to make it work. Or rather, I could get it working, but only if a kicker method was called before calling #destroyed?.
It clears the keys and the subjects (properties), forcing lazy-loading to take place, which actually happens in the Collection, not the Resource per se. Since #reload is invoked on the Resource, I was able to force that lazy-loading to occur (in the Collection), then consult the Collection to check if self is still in it. If self (the Resource in question) has mysteriously disappeared from the Collection, then I set the persistence state (to what, I forget... I think Immutable, which plays a role in whether or not #destroyed? returns true). The issue I was running into, and not entirely sure why, was that calling #reload on a clean resource wasn't having any impact, but calling it on a dirty resource was doing exactly what I wanted, marking the resource as destroyed, after observing itself disappear from the Collection. I eventually gave in and accepted defeat ;)
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'll have a look at this later, but to me, it seems logical that the following behaviour should not exhibit:
In process A:
In process B, simultaneously (or in the same process without the identity map):
To me, since we have a persisted state that indicates the resource is saved, yet we've failed to find the resource when doing a reload (note no exception is thrown), the resource should be flagged as destroyed.
This crops up in rails specs trying to assert that a record has been destroyed by a controller (in a semantic way).
The text was updated successfully, but these errors were encountered: