mongoid_identity_map 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,12 +7,18 @@ module MongoidIdentityMap
7
7
 
8
8
  included do
9
9
  alias_method_chain :remove, :identity_map
10
+ alias_method_chain :update, :identity_map
10
11
  end
11
12
 
12
13
  def remove_with_identity_map(options = {})
13
14
  IdentityMap.remove(self)
14
15
  self.remove_without_identity_map(options)
15
16
  end
17
+
18
+ def update_with_identity_map(options = {})
19
+ IdentityMap.remove(self)
20
+ self.update_without_identity_map(options)
21
+ end
16
22
  end
17
23
  end
18
24
  end
@@ -1,3 +1,3 @@
1
1
  module MongoidIdentityMap
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.add_dependency "activesupport", "~> 3.0"
18
18
  s.add_dependency "mongoid", "~> 2.0"
19
19
 
20
+ s.add_development_dependency "rake"
20
21
  s.add_development_dependency "bson_ext", ">= 1.3.0"
21
22
  s.add_development_dependency "bundler", ">= 1.0.0"
22
23
  s.add_development_dependency "rspec", ">= 2.5.0"
@@ -73,6 +73,8 @@ describe MongoidIdentityMap::IdentityMap do
73
73
  end
74
74
 
75
75
  describe ".remove" do
76
+ let(:same_model_different_instance) {Model.new(model.attributes)}
77
+
76
78
  before do
77
79
  MongoidIdentityMap::IdentityMap.set(key, model)
78
80
  end
@@ -81,6 +83,16 @@ describe MongoidIdentityMap::IdentityMap do
81
83
  MongoidIdentityMap::IdentityMap.remove(model)
82
84
  MongoidIdentityMap::IdentityMap.get(key).should be_nil
83
85
  end
86
+
87
+ it "should remove every occurrence of a model from identity map" do
88
+ MongoidIdentityMap::IdentityMap.set(:key, model)
89
+ MongoidIdentityMap::IdentityMap.set(:key2, model)
90
+ MongoidIdentityMap::IdentityMap.set(:key3, same_model_different_instance)
91
+ MongoidIdentityMap::IdentityMap.remove(model)
92
+ MongoidIdentityMap::IdentityMap.get(:key).should be_nil
93
+ MongoidIdentityMap::IdentityMap.get(:key2).should be_nil
94
+ MongoidIdentityMap::IdentityMap.get(:key3).should be_nil
95
+ end
84
96
  end
85
97
 
86
98
  describe ".clear" do
@@ -19,4 +19,23 @@ describe MongoidIdentityMap::Persistence::IdentityMappable do
19
19
  @model.remove(options)
20
20
  end
21
21
  end
22
+
23
+ describe "#update" do
24
+ before do
25
+ @model = Model.new
26
+ @model.stub!(:update_without_identity_map)
27
+ MongoidIdentityMap::IdentityMap.stub!(:update)
28
+ end
29
+
30
+ it "should remove document from identity map" do
31
+ MongoidIdentityMap::IdentityMap.should_receive(:remove).with(@model)
32
+ @model.update
33
+ end
34
+
35
+ it "should update document in database" do
36
+ options = {:opt1 => :val1}
37
+ @model.should_receive(:update_without_identity_map).with(options)
38
+ @model.update(options)
39
+ end
40
+ end
22
41
  end
metadata CHANGED
@@ -1,105 +1,90 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mongoid_identity_map
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 3
8
- - 1
9
- version: 0.3.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Guilherme Cirne
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-05-10 00:00:00 -03:00
12
+ date: 2011-06-27 00:00:00.000000000 -03:00
18
13
  default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
21
16
  name: activesupport
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2161394660 !ruby/object:Gem::Requirement
24
18
  none: false
25
- requirements:
19
+ requirements:
26
20
  - - ~>
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 3
30
- - 0
31
- version: "3.0"
21
+ - !ruby/object:Gem::Version
22
+ version: '3.0'
32
23
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: mongoid
36
24
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *2161394660
26
+ - !ruby/object:Gem::Dependency
27
+ name: mongoid
28
+ requirement: &2161394200 !ruby/object:Gem::Requirement
38
29
  none: false
39
- requirements:
30
+ requirements:
40
31
  - - ~>
41
- - !ruby/object:Gem::Version
42
- segments:
43
- - 2
44
- - 0
45
- version: "2.0"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
46
34
  type: :runtime
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: bson_ext
50
35
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *2161394200
37
+ - !ruby/object:Gem::Dependency
38
+ name: rake
39
+ requirement: &2161393820 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *2161393820
48
+ - !ruby/object:Gem::Dependency
49
+ name: bson_ext
50
+ requirement: &2161393280 !ruby/object:Gem::Requirement
52
51
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- segments:
57
- - 1
58
- - 3
59
- - 0
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
60
55
  version: 1.3.0
61
56
  type: :development
62
- version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
64
- name: bundler
65
57
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
58
+ version_requirements: *2161393280
59
+ - !ruby/object:Gem::Dependency
60
+ name: bundler
61
+ requirement: &2161416580 !ruby/object:Gem::Requirement
67
62
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- segments:
72
- - 1
73
- - 0
74
- - 0
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
75
66
  version: 1.0.0
76
67
  type: :development
77
- version_requirements: *id004
78
- - !ruby/object:Gem::Dependency
79
- name: rspec
80
68
  prerelease: false
81
- requirement: &id005 !ruby/object:Gem::Requirement
69
+ version_requirements: *2161416580
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ requirement: &2161416120 !ruby/object:Gem::Requirement
82
73
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- segments:
87
- - 2
88
- - 5
89
- - 0
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
90
77
  version: 2.5.0
91
78
  type: :development
92
- version_requirements: *id005
79
+ prerelease: false
80
+ version_requirements: *2161416120
93
81
  description: Simple and transparent Identity Map implementation for Mongoid
94
- email:
82
+ email:
95
83
  - gcirne@gmail.com
96
84
  executables: []
97
-
98
85
  extensions: []
99
-
100
86
  extra_rdoc_files: []
101
-
102
- files:
87
+ files:
103
88
  - .gitignore
104
89
  - .rvmrc
105
90
  - .travis.yml
@@ -123,36 +108,26 @@ files:
123
108
  has_rdoc: true
124
109
  homepage: http://rubygems.org/gems/mongoid_identity_map
125
110
  licenses: []
126
-
127
111
  post_install_message:
128
112
  rdoc_options: []
129
-
130
- require_paths:
113
+ require_paths:
131
114
  - lib
132
- required_ruby_version: !ruby/object:Gem::Requirement
115
+ required_ruby_version: !ruby/object:Gem::Requirement
133
116
  none: false
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- segments:
138
- - 0
139
- version: "0"
140
- required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
122
  none: false
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- segments:
146
- - 1
147
- - 3
148
- - 6
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
149
126
  version: 1.3.6
150
127
  requirements: []
151
-
152
128
  rubyforge_project: mongoid_identity_map
153
- rubygems_version: 1.3.7
129
+ rubygems_version: 1.6.2
154
130
  signing_key:
155
131
  specification_version: 3
156
132
  summary: IdentityMap for Mongoid
157
133
  test_files: []
158
-