bullet 2.3.0 → 2.3.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/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
bullet (2.3.
|
|
4
|
+
bullet (2.3.1)
|
|
5
5
|
uniform_notifier (~> 1.0.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -104,7 +104,7 @@ GEM
|
|
|
104
104
|
polyglot
|
|
105
105
|
polyglot (>= 0.3.1)
|
|
106
106
|
tzinfo (0.3.32)
|
|
107
|
-
uniform_notifier (1.0.
|
|
107
|
+
uniform_notifier (1.0.2)
|
|
108
108
|
|
|
109
109
|
PLATFORMS
|
|
110
110
|
ruby
|
data/README.textile
CHANGED
|
@@ -20,29 +20,29 @@ module Bullet
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def add_object_associations(object, associations)
|
|
23
|
-
object_associations.add(object.ar_key, associations)
|
|
23
|
+
object_associations.add(object.ar_key, associations) if object.id
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def add_call_object_associations(object, associations)
|
|
27
|
-
if object.id
|
|
28
|
-
call_object_associations.add(object.ar_key, associations)
|
|
29
|
-
end
|
|
27
|
+
call_object_associations.add(object.ar_key, associations) if object.id
|
|
30
28
|
end
|
|
31
29
|
|
|
32
30
|
def add_possible_objects(object_or_objects)
|
|
33
31
|
if object_or_objects.is_a? Array
|
|
34
32
|
object_or_objects.each { |object| possible_objects.add object.ar_key }
|
|
33
|
+
elsif object_or_objects.is_a? ::ActiveRecord::Base
|
|
34
|
+
possible_objects.add object_or_objects.ar_key if object_or_objects.id
|
|
35
35
|
else
|
|
36
|
-
|
|
36
|
+
# do nothing
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def add_impossible_object(object)
|
|
41
|
-
impossible_objects.add object.ar_key
|
|
41
|
+
impossible_objects.add object.ar_key if object.id
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def add_eager_loadings(objects, associations)
|
|
45
|
-
object_ar_keys =
|
|
45
|
+
object_ar_keys = objects.map(&:ar_key)
|
|
46
46
|
|
|
47
47
|
to_add = nil
|
|
48
48
|
to_merge, to_delete = [], []
|
data/lib/bullet/version.rb
CHANGED
|
@@ -47,6 +47,10 @@ module Bullet
|
|
|
47
47
|
Association.send(:possible_objects).should be_include(@post1.ar_key)
|
|
48
48
|
Association.send(:possible_objects).should be_include(@post2.ar_key)
|
|
49
49
|
end
|
|
50
|
+
|
|
51
|
+
it "should not raise error if object is nil" do
|
|
52
|
+
lambda { Association.add_possible_objects(nil) }.should_not raise_error
|
|
53
|
+
end
|
|
50
54
|
end
|
|
51
55
|
|
|
52
56
|
context ".add_impossible_object" do
|
|
@@ -70,7 +74,7 @@ module Bullet
|
|
|
70
74
|
end
|
|
71
75
|
|
|
72
76
|
it "should merge objects, associations pair for existing eager_loadings" do
|
|
73
|
-
Association.add_eager_loadings(@post1, :association1)
|
|
77
|
+
Association.add_eager_loadings([@post1], :association1)
|
|
74
78
|
Association.add_eager_loadings([@post1, @post2], :association2)
|
|
75
79
|
Association.send(:eager_loadings).should be_include([@post1.ar_key], :association1)
|
|
76
80
|
Association.send(:eager_loadings).should be_include([@post1.ar_key], :association2)
|
|
@@ -79,7 +83,7 @@ module Bullet
|
|
|
79
83
|
|
|
80
84
|
it "should delete objects, associations pair for existing eager_loadings" do
|
|
81
85
|
Association.add_eager_loadings([@post1, @post2], :association1)
|
|
82
|
-
Association.add_eager_loadings(@post1, :association2)
|
|
86
|
+
Association.add_eager_loadings([@post1], :association2)
|
|
83
87
|
Association.send(:eager_loadings).should be_include([@post1.ar_key], :association1)
|
|
84
88
|
Association.send(:eager_loadings).should be_include([@post1.ar_key], :association2)
|
|
85
89
|
Association.send(:eager_loadings).should be_include([@post2.ar_key], :association1)
|
|
@@ -12,13 +12,13 @@ module Bullet
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
it "should get call associations if object and association are both in eager_loadings and call_object_associations" do
|
|
15
|
-
UnusedEagerAssociation.add_eager_loadings(@post, :association)
|
|
15
|
+
UnusedEagerAssociation.add_eager_loadings([@post], :association)
|
|
16
16
|
UnusedEagerAssociation.add_call_object_associations(@post, :association)
|
|
17
17
|
UnusedEagerAssociation.send(:call_associations, @post.ar_key, Set.new([:association])).should == [:association]
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it "should not get call associations if not exist in call_object_associations" do
|
|
21
|
-
UnusedEagerAssociation.add_eager_loadings(@post, :association)
|
|
21
|
+
UnusedEagerAssociation.add_eager_loadings([@post], :association)
|
|
22
22
|
UnusedEagerAssociation.send(:call_associations, @post.ar_key, Set.new([:association])).should be_empty
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -29,7 +29,7 @@ module Bullet
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it "should return empty if associations exist in call_association" do
|
|
32
|
-
UnusedEagerAssociation.add_eager_loadings(@post, :association)
|
|
32
|
+
UnusedEagerAssociation.add_eager_loadings([@post], :association)
|
|
33
33
|
UnusedEagerAssociation.add_call_object_associations(@post, :association)
|
|
34
34
|
UnusedEagerAssociation.send(:diff_object_association, @post.ar_key, Set.new([:association])).should be_empty
|
|
35
35
|
end
|
|
@@ -50,7 +50,7 @@ module Bullet
|
|
|
50
50
|
it "should not create notification if object_association_diff is empty" do
|
|
51
51
|
UnusedEagerAssociation.clear
|
|
52
52
|
UnusedEagerAssociation.add_object_associations(@post, :association)
|
|
53
|
-
UnusedEagerAssociation.add_eager_loadings(@post, :association)
|
|
53
|
+
UnusedEagerAssociation.add_eager_loadings([@post], :association)
|
|
54
54
|
UnusedEagerAssociation.add_call_object_associations(@post, :association)
|
|
55
55
|
UnusedEagerAssociation.send(:diff_object_association, @post.ar_key, Set.new([:association])).should be_empty
|
|
56
56
|
UnusedEagerAssociation.should_not_receive(:create_notification).with("Post", [:association])
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bullet
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.3.
|
|
4
|
+
version: 2.3.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-04-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: uniform_notifier
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &70233469813360 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ~>
|
|
@@ -21,7 +21,7 @@ dependencies:
|
|
|
21
21
|
version: 1.0.0
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *70233469813360
|
|
25
25
|
description: A rails plugin to kill N+1 queries and unused eager loading.
|
|
26
26
|
email:
|
|
27
27
|
- flyerhzm@gmail.com
|
|
@@ -134,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
134
134
|
version: '0'
|
|
135
135
|
segments:
|
|
136
136
|
- 0
|
|
137
|
-
hash:
|
|
137
|
+
hash: 3928584312604954980
|
|
138
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
none: false
|
|
140
140
|
requirements:
|