describe "#instantiate", :focus => true do
context "all links are dead" do
it "should remove links that could not be instantiated" do
@person.robject.links << @task.to_link("tasks")
@person.tasks.inspect # trigger load_object
@person.robject.links.should be_empty
end
end
context "only some links are dead" do
it "should remove links that could not be instantiated" do
@person.robject.links << @task.to_link("tasks")
@person.tasks << @other_task
@person.tasks.inspect
@person.robject.links.should have(1).item
@person.robject.links.should include(@other_task.to_link("tasks"))
end
end
context "owner also links to objects of another type" do
it "should only remove dead links of the accessed association" do
@person.profile = @profile
@person.robject.links << @task.to_link("tasks")
@person.robject.links.should have(2).item
@person.tasks.inspect
@person.robject.links.should have(1).item
end
end
end
Would be nice to perform read repair and remove dead links from the robject from within Ripple as objects are retrieved from Riak.
Currently operations like #count on a Ripple::Document use keys.count which includes dead links. https://github.com/basho/ripple/blob/master/lib/ripple/associations/many_linked_proxy.rb#L11-14
Iterating over collections also requires rejecting nil values that result from dead links.
My thought is to perform link cleanup after calls to find_target. https://github.com/basho/ripple/blob/master/lib/ripple/associations/many_linked_proxy.rb#L48-59
Here are tests to describe the desired behavior that could be added to https://github.com/basho/ripple/blob/master/spec/ripple/associations/many_linked_proxy_spec.rb: