mongoid_identity_map 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +6 -0
 - data/README.md +28 -0
 - data/Rakefile +2 -0
 - data/lib/mongoid_identity_map.rb +2 -2
 - data/lib/mongoid_identity_map/clear_middleware.rb +1 -1
 - data/lib/mongoid_identity_map/identity_map.rb +5 -1
 - data/lib/mongoid_identity_map/railtie.rb +7 -0
 - data/lib/mongoid_identity_map/{current_thread_hash.rb → thread_local_hash.rb} +4 -4
 - data/lib/mongoid_identity_map/version.rb +1 -1
 - data/mongoid_identity_map.gemspec +3 -3
 - data/spec/mongoid_identity_map/clear_middleware_spec.rb +1 -1
 - data/spec/mongoid_identity_map/identity_map_spec.rb +14 -7
 - data/spec/mongoid_identity_map/thread_local_hash_spec.rb +30 -0
 - data/spec/spec_helper.rb +1 -1
 - metadata +11 -10
 - data/spec/mongoid_identity_map/current_thread_hash_spec.rb +0 -30
 
    
        data/.travis.yml
    ADDED
    
    
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Mongoid Identity Map
         
     | 
| 
      
 2 
     | 
    
         
            +
            ====================
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            ## About [](http://travis-ci.org/gcirne/mongoid_identity_map)
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Mongoid Identity Map is a simple and transparent Identity Map implementation for the Mongoid ODM.
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            [Mongoid](http://mongoid.org)
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            [Identity Map pattern](http://martinfowler.com/eaaCatalog/identityMap.html)
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            In Gemfile:
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                gem "mongoid_identity_map"
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            ## Configuration
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            Add rack middleware `MongoidIdentityMap::ClearMiddleware` for clearing identity map after each request.
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            When using this gem in a Rails app this is done automatically.
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            ## Current Limitations
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            Currently, it's an all or nothing deal. It is not possible to turn the identiy map on or off on a class (Mongoid::Document) basis.
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            Identity map is applied only on Mongoid's Collection find_one method. The find method doesn't have the identity map applied.
         
     | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/lib/mongoid_identity_map.rb
    CHANGED
    
    | 
         @@ -1,5 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "mongoid_identity_map/clear_middleware"
         
     | 
| 
       2 
     | 
    
         
            -
            require "mongoid_identity_map/ 
     | 
| 
      
 2 
     | 
    
         
            +
            require "mongoid_identity_map/thread_local_hash"
         
     | 
| 
       3 
3 
     | 
    
         
             
            require "mongoid_identity_map/identity_map"
         
     | 
| 
       4 
4 
     | 
    
         
             
            require "mongoid_identity_map/identity_mappable"
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
            require "mongoid_identity_map/railtie" if defined?(Rails)
         
     | 
| 
         @@ -3,7 +3,11 @@ module MongoidIdentityMap 
     | 
|
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
                class << self
         
     | 
| 
       5 
5 
     | 
    
         
             
                  def fetch(selector)
         
     | 
| 
       6 
     | 
    
         
            -
                     
     | 
| 
      
 6 
     | 
    
         
            +
                    ThreadLocalHash.get(selector) || ThreadLocalHash.set(selector, yield)
         
     | 
| 
      
 7 
     | 
    
         
            +
                  end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  def clear
         
     | 
| 
      
 10 
     | 
    
         
            +
                    ThreadLocalHash.clear
         
     | 
| 
       7 
11 
     | 
    
         
             
                  end
         
     | 
| 
       8 
12 
     | 
    
         
             
                end
         
     | 
| 
       9 
13 
     | 
    
         | 
| 
         @@ -1,12 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module MongoidIdentityMap
         
     | 
| 
       2 
     | 
    
         
            -
              class  
     | 
| 
      
 2 
     | 
    
         
            +
              class ThreadLocalHash
         
     | 
| 
       3 
3 
     | 
    
         
             
                class << self
         
     | 
| 
       4 
4 
     | 
    
         
             
                  def get(key)
         
     | 
| 
       5 
     | 
    
         
            -
                     
     | 
| 
      
 5 
     | 
    
         
            +
                    thread_local_hash[key]
         
     | 
| 
       6 
6 
     | 
    
         
             
                  end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def set(key, value)
         
     | 
| 
       9 
     | 
    
         
            -
                     
     | 
| 
      
 9 
     | 
    
         
            +
                    thread_local_hash[key] = value
         
     | 
| 
       10 
10 
     | 
    
         
             
                  end
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
                  def clear
         
     | 
| 
         @@ -15,7 +15,7 @@ module MongoidIdentityMap 
     | 
|
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
                  private
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
                  def  
     | 
| 
      
 18 
     | 
    
         
            +
                  def thread_local_hash
         
     | 
| 
       19 
19 
     | 
    
         
             
                    Thread.current[:mongoid_identity_map_current_thread_hash] ||= Hash.new
         
     | 
| 
       20 
20 
     | 
    
         
             
                  end
         
     | 
| 
       21 
21 
     | 
    
         
             
                end
         
     | 
| 
         @@ -9,13 +9,13 @@ Gem::Specification.new do |s| 
     | 
|
| 
       9 
9 
     | 
    
         
             
              s.email       = ["gcirne@gmail.com"]
         
     | 
| 
       10 
10 
     | 
    
         
             
              s.homepage    = "http://rubygems.org/gems/mongoid_identity_map"
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.summary     = "IdentityMap for Mongoid"
         
     | 
| 
       12 
     | 
    
         
            -
              s.description = "Simple and transparent  
     | 
| 
      
 12 
     | 
    
         
            +
              s.description = "Simple and transparent Identity Map implementation for Mongoid"
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
              s.required_rubygems_version = ">= 1.3.6"
         
     | 
| 
       15 
15 
     | 
    
         
             
              s.rubyforge_project         = "mongoid_identity_map"
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
              s.add_dependency "activesupport", "~> 3.0 
     | 
| 
       18 
     | 
    
         
            -
              s.add_dependency "mongoid", "~> 2.0 
     | 
| 
      
 17 
     | 
    
         
            +
              s.add_dependency "activesupport", "~> 3.0"
         
     | 
| 
      
 18 
     | 
    
         
            +
              s.add_dependency "mongoid", "~> 2.0"
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
              s.add_development_dependency "bson_ext", ">= 1.3.0"
         
     | 
| 
       21 
21 
     | 
    
         
             
              s.add_development_dependency "bundler", ">= 1.0.0"
         
     | 
| 
         @@ -14,7 +14,7 @@ describe MongoidIdentityMap::ClearMiddleware do 
     | 
|
| 
       14 
14 
     | 
    
         
             
              end
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
              it "should clear identity map" do
         
     | 
| 
       17 
     | 
    
         
            -
                MongoidIdentityMap:: 
     | 
| 
      
 17 
     | 
    
         
            +
                MongoidIdentityMap::IdentityMap.should_receive(:clear)
         
     | 
| 
       18 
18 
     | 
    
         
             
                @clear_middleware.call(@env)
         
     | 
| 
       19 
19 
     | 
    
         
             
              end
         
     | 
| 
       20 
20 
     | 
    
         
             
            end
         
     | 
| 
         @@ -7,9 +7,15 @@ describe MongoidIdentityMap::IdentityMap do 
     | 
|
| 
       7 
7 
     | 
    
         
             
              end
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
              describe ".fetch" do
         
     | 
| 
      
 10 
     | 
    
         
            +
                let (:fetch) do
         
     | 
| 
      
 11 
     | 
    
         
            +
                  MongoidIdentityMap::IdentityMap.fetch(@selector) do
         
     | 
| 
      
 12 
     | 
    
         
            +
                    Model.collection.find_one_without_identity_map(@selector)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
       10 
16 
     | 
    
         
             
                context "when document doesn't exist in identity map" do
         
     | 
| 
       11 
17 
     | 
    
         
             
                  before do
         
     | 
| 
       12 
     | 
    
         
            -
                    MongoidIdentityMap:: 
     | 
| 
      
 18 
     | 
    
         
            +
                    MongoidIdentityMap::ThreadLocalHash.stub!(:get).with(@selector).and_return(nil)
         
     | 
| 
       13 
19 
     | 
    
         
             
                    Model.collection.stub!(:find_one_without_identity_map).with(@selector).and_return(@model)
         
     | 
| 
       14 
20 
     | 
    
         
             
                  end
         
     | 
| 
       15 
21 
     | 
    
         | 
| 
         @@ -19,14 +25,14 @@ describe MongoidIdentityMap::IdentityMap do 
     | 
|
| 
       19 
25 
     | 
    
         
             
                  end
         
     | 
| 
       20 
26 
     | 
    
         | 
| 
       21 
27 
     | 
    
         
             
                  it "should set document in identity map" do
         
     | 
| 
       22 
     | 
    
         
            -
                    MongoidIdentityMap:: 
     | 
| 
      
 28 
     | 
    
         
            +
                    MongoidIdentityMap::ThreadLocalHash.should_receive(:set).with(@selector, @model)
         
     | 
| 
       23 
29 
     | 
    
         
             
                    fetch
         
     | 
| 
       24 
30 
     | 
    
         
             
                  end
         
     | 
| 
       25 
31 
     | 
    
         
             
                end
         
     | 
| 
       26 
32 
     | 
    
         | 
| 
       27 
33 
     | 
    
         
             
                context "when document exists in identity map" do
         
     | 
| 
       28 
34 
     | 
    
         
             
                  before do
         
     | 
| 
       29 
     | 
    
         
            -
                    MongoidIdentityMap:: 
     | 
| 
      
 35 
     | 
    
         
            +
                    MongoidIdentityMap::ThreadLocalHash.stub!(:get).with(@selector).and_return(@model)
         
     | 
| 
       30 
36 
     | 
    
         
             
                  end
         
     | 
| 
       31 
37 
     | 
    
         | 
| 
       32 
38 
     | 
    
         
             
                  it "should return document from identity map" do
         
     | 
| 
         @@ -38,11 +44,12 @@ describe MongoidIdentityMap::IdentityMap do 
     | 
|
| 
       38 
44 
     | 
    
         
             
                    fetch
         
     | 
| 
       39 
45 
     | 
    
         
             
                  end
         
     | 
| 
       40 
46 
     | 
    
         
             
                end
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
       41 
48 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                   
     | 
| 
      
 49 
     | 
    
         
            +
              describe ".clear" do
         
     | 
| 
      
 50 
     | 
    
         
            +
                it "should clear identity map" do
         
     | 
| 
      
 51 
     | 
    
         
            +
                  MongoidIdentityMap::ThreadLocalHash.should_receive(:clear)
         
     | 
| 
      
 52 
     | 
    
         
            +
                  MongoidIdentityMap::IdentityMap.clear
         
     | 
| 
       46 
53 
     | 
    
         
             
                end
         
     | 
| 
       47 
54 
     | 
    
         
             
              end
         
     | 
| 
       48 
55 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe MongoidIdentityMap::ThreadLocalHash do
         
     | 
| 
      
 4 
     | 
    
         
            +
              describe ".set and .get" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                it "should set and get key based value" do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  MongoidIdentityMap::ThreadLocalHash.set(:key, "value")
         
     | 
| 
      
 7 
     | 
    
         
            +
                  
         
     | 
| 
      
 8 
     | 
    
         
            +
                  Thread.new do
         
     | 
| 
      
 9 
     | 
    
         
            +
                    MongoidIdentityMap::ThreadLocalHash.set(:key, "value2")
         
     | 
| 
      
 10 
     | 
    
         
            +
                    MongoidIdentityMap::ThreadLocalHash.get(:key).should == "value2"
         
     | 
| 
      
 11 
     | 
    
         
            +
                  end.join
         
     | 
| 
      
 12 
     | 
    
         
            +
                  
         
     | 
| 
      
 13 
     | 
    
         
            +
                  MongoidIdentityMap::ThreadLocalHash.get(:key).should == "value"
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
              
         
     | 
| 
      
 17 
     | 
    
         
            +
              describe ".clear" do
         
     | 
| 
      
 18 
     | 
    
         
            +
                it "should clear" do
         
     | 
| 
      
 19 
     | 
    
         
            +
                  MongoidIdentityMap::ThreadLocalHash.set(:key, "value")
         
     | 
| 
      
 20 
     | 
    
         
            +
                  
         
     | 
| 
      
 21 
     | 
    
         
            +
                  Thread.new do
         
     | 
| 
      
 22 
     | 
    
         
            +
                    MongoidIdentityMap::ThreadLocalHash.set(:key, "value")
         
     | 
| 
      
 23 
     | 
    
         
            +
                    MongoidIdentityMap::ThreadLocalHash.clear
         
     | 
| 
      
 24 
     | 
    
         
            +
                    MongoidIdentityMap::ThreadLocalHash.get(:key).should be_nil
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end.join
         
     | 
| 
      
 26 
     | 
    
         
            +
                  
         
     | 
| 
      
 27 
     | 
    
         
            +
                  MongoidIdentityMap::ThreadLocalHash.get(:key).should == "value"
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version 
     | 
|
| 
       4 
4 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       5 
5 
     | 
    
         
             
              segments: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              - 0
         
     | 
| 
       7 
     | 
    
         
            -
              - 0
         
     | 
| 
       8 
7 
     | 
    
         
             
              - 1
         
     | 
| 
       9 
     | 
    
         
            -
               
     | 
| 
      
 8 
     | 
    
         
            +
              - 1
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.1.1
         
     | 
| 
       10 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       11 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       12 
12 
     | 
    
         
             
            - Guilherme Cirne
         
     | 
| 
         @@ -14,7 +14,7 @@ autorequire: 
     | 
|
| 
       14 
14 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       15 
15 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
            date: 2011- 
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2011-05-02 00:00:00 -03:00
         
     | 
| 
       18 
18 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       19 
19 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       20 
20 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -28,8 +28,7 @@ dependencies: 
     | 
|
| 
       28 
28 
     | 
    
         
             
                    segments: 
         
     | 
| 
       29 
29 
     | 
    
         
             
                    - 3
         
     | 
| 
       30 
30 
     | 
    
         
             
                    - 0
         
     | 
| 
       31 
     | 
    
         
            -
                     
     | 
| 
       32 
     | 
    
         
            -
                    version: 3.0.0
         
     | 
| 
      
 31 
     | 
    
         
            +
                    version: "3.0"
         
     | 
| 
       33 
32 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       34 
33 
     | 
    
         
             
              version_requirements: *id001
         
     | 
| 
       35 
34 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -43,8 +42,7 @@ dependencies: 
     | 
|
| 
       43 
42 
     | 
    
         
             
                    segments: 
         
     | 
| 
       44 
43 
     | 
    
         
             
                    - 2
         
     | 
| 
       45 
44 
     | 
    
         
             
                    - 0
         
     | 
| 
       46 
     | 
    
         
            -
                     
     | 
| 
       47 
     | 
    
         
            -
                    version: 2.0.0
         
     | 
| 
      
 45 
     | 
    
         
            +
                    version: "2.0"
         
     | 
| 
       48 
46 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       49 
47 
     | 
    
         
             
              version_requirements: *id002
         
     | 
| 
       50 
48 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -92,7 +90,7 @@ dependencies: 
     | 
|
| 
       92 
90 
     | 
    
         
             
                    version: 2.5.0
         
     | 
| 
       93 
91 
     | 
    
         
             
              type: :development
         
     | 
| 
       94 
92 
     | 
    
         
             
              version_requirements: *id005
         
     | 
| 
       95 
     | 
    
         
            -
            description: Simple and transparent  
     | 
| 
      
 93 
     | 
    
         
            +
            description: Simple and transparent Identity Map implementation for Mongoid
         
     | 
| 
       96 
94 
     | 
    
         
             
            email: 
         
     | 
| 
       97 
95 
     | 
    
         
             
            - gcirne@gmail.com
         
     | 
| 
       98 
96 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -104,19 +102,22 @@ extra_rdoc_files: [] 
     | 
|
| 
       104 
102 
     | 
    
         
             
            files: 
         
     | 
| 
       105 
103 
     | 
    
         
             
            - .gitignore
         
     | 
| 
       106 
104 
     | 
    
         
             
            - .rvmrc
         
     | 
| 
      
 105 
     | 
    
         
            +
            - .travis.yml
         
     | 
| 
       107 
106 
     | 
    
         
             
            - Gemfile
         
     | 
| 
      
 107 
     | 
    
         
            +
            - README.md
         
     | 
| 
       108 
108 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       109 
109 
     | 
    
         
             
            - lib/mongoid_identity_map.rb
         
     | 
| 
       110 
110 
     | 
    
         
             
            - lib/mongoid_identity_map/clear_middleware.rb
         
     | 
| 
       111 
     | 
    
         
            -
            - lib/mongoid_identity_map/current_thread_hash.rb
         
     | 
| 
       112 
111 
     | 
    
         
             
            - lib/mongoid_identity_map/identity_map.rb
         
     | 
| 
       113 
112 
     | 
    
         
             
            - lib/mongoid_identity_map/identity_mappable.rb
         
     | 
| 
      
 113 
     | 
    
         
            +
            - lib/mongoid_identity_map/railtie.rb
         
     | 
| 
      
 114 
     | 
    
         
            +
            - lib/mongoid_identity_map/thread_local_hash.rb
         
     | 
| 
       114 
115 
     | 
    
         
             
            - lib/mongoid_identity_map/version.rb
         
     | 
| 
       115 
116 
     | 
    
         
             
            - mongoid_identity_map.gemspec
         
     | 
| 
       116 
117 
     | 
    
         
             
            - spec/mongoid_identity_map/clear_middleware_spec.rb
         
     | 
| 
       117 
     | 
    
         
            -
            - spec/mongoid_identity_map/current_thread_hash_spec.rb
         
     | 
| 
       118 
118 
     | 
    
         
             
            - spec/mongoid_identity_map/identity_map_spec.rb
         
     | 
| 
       119 
119 
     | 
    
         
             
            - spec/mongoid_identity_map/identity_mappable_spec.rb
         
     | 
| 
      
 120 
     | 
    
         
            +
            - spec/mongoid_identity_map/thread_local_hash_spec.rb
         
     | 
| 
       120 
121 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       121 
122 
     | 
    
         
             
            - spec/support/model.rb
         
     | 
| 
       122 
123 
     | 
    
         
             
            has_rdoc: true
         
     | 
| 
         @@ -1,30 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require "spec_helper"
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe MongoidIdentityMap::CurrentThreadHash do
         
     | 
| 
       4 
     | 
    
         
            -
              describe ".set and .get" do
         
     | 
| 
       5 
     | 
    
         
            -
                it "should set and get key based value" do
         
     | 
| 
       6 
     | 
    
         
            -
                  MongoidIdentityMap::CurrentThreadHash.set(:key, "value")
         
     | 
| 
       7 
     | 
    
         
            -
                  
         
     | 
| 
       8 
     | 
    
         
            -
                  Thread.new do
         
     | 
| 
       9 
     | 
    
         
            -
                    MongoidIdentityMap::CurrentThreadHash.set(:key, "value2")
         
     | 
| 
       10 
     | 
    
         
            -
                    MongoidIdentityMap::CurrentThreadHash.get(:key).should == "value2"
         
     | 
| 
       11 
     | 
    
         
            -
                  end.join
         
     | 
| 
       12 
     | 
    
         
            -
                  
         
     | 
| 
       13 
     | 
    
         
            -
                  MongoidIdentityMap::CurrentThreadHash.get(:key).should == "value"
         
     | 
| 
       14 
     | 
    
         
            -
                end
         
     | 
| 
       15 
     | 
    
         
            -
              end
         
     | 
| 
       16 
     | 
    
         
            -
              
         
     | 
| 
       17 
     | 
    
         
            -
              describe ".clear" do
         
     | 
| 
       18 
     | 
    
         
            -
                it "should clear" do
         
     | 
| 
       19 
     | 
    
         
            -
                  MongoidIdentityMap::CurrentThreadHash.set(:key, "value")
         
     | 
| 
       20 
     | 
    
         
            -
                  
         
     | 
| 
       21 
     | 
    
         
            -
                  Thread.new do
         
     | 
| 
       22 
     | 
    
         
            -
                    MongoidIdentityMap::CurrentThreadHash.set(:key, "value")
         
     | 
| 
       23 
     | 
    
         
            -
                    MongoidIdentityMap::CurrentThreadHash.clear
         
     | 
| 
       24 
     | 
    
         
            -
                    MongoidIdentityMap::CurrentThreadHash.get(:key).should be_nil
         
     | 
| 
       25 
     | 
    
         
            -
                  end.join
         
     | 
| 
       26 
     | 
    
         
            -
                  
         
     | 
| 
       27 
     | 
    
         
            -
                  MongoidIdentityMap::CurrentThreadHash.get(:key).should == "value"
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
       30 
     | 
    
         
            -
            end
         
     |