#333 invalid
Adam French

Identity Map needs to be better documented

Reported by Adam French | May 31st, 2008 @ 12:43 PM

in all our hard work to get things going again in 0.9, we seem to have forgotten to consult the Identity Map before we re-instantiate objects.

integration/repository_spec.rb

      describe "use of the identity map" do
        
        it "should add an instance into it's identity map" do
          foo = repository(ADAPTER).first(SerialFinderSpec, {})
          foo.should_not be_nil
          repository(ADAPTER).identity_map(SerialFinderSpec).get(foo.key).should == foo
        end
        
        it "should pull out a single instance from the repo only once (identity map)" do
          pending
          foo = repository(ADAPTER).first(SerialFinderSpec, {})
          foo.should_not be_nil

          bar = repository(ADAPTER).first(SerialFinderSpec, {:id => foo.id})
          bar.should == foo
          bar.object_id.should == foo.object_id
        end
        
      end

Comments and changes to this ticket

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) June 1st, 2008 @ 06:14 PM

    I believe this is by design. IdentityMap only works inside a repository block. It goes out of scope when the containing repository also goes out of scope.

  • Adam French

    Adam French June 1st, 2008 @ 06:56 PM

    • Title changed from “!! Identity Map not consulted during retrieval” to “Identity Map not consulted during retrieval”

    ok, so we should make this much more clear in the documentation for people who are seeing the ID not being consulted. Hell, it confused me and ends up that we actually wrap our merb Application#dispatch action inside a repo context....so I guess I got spoiled by this and forgot it.

  • Adam French

    Adam French June 1st, 2008 @ 06:57 PM

    • Title changed from “Identity Map not consulted during retrieval” to “Identity Map needs to be better documented”
  • Sam Smoot

    Sam Smoot June 2nd, 2008 @ 04:01 PM

    • State changed from “new” to “invalid”

    Marking as invalid. ;-) Doc ticket can be separate.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Referenced by

Pages