bullet 5.4.2 → 5.5.0
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -92
- data/CHANGELOG.md +6 -5
- data/Gemfile.mongoid-5.0 +1 -1
- data/{Gemfile.mongoid-2.4 → Gemfile.mongoid-6.0} +2 -2
- data/README.md +5 -3
- data/lib/bullet/active_record4.rb +9 -4
- data/lib/bullet/active_record41.rb +12 -8
- data/lib/bullet/active_record42.rb +13 -21
- data/lib/bullet/active_record5.rb +7 -2
- data/lib/bullet/dependency.rb +8 -34
- data/lib/bullet/{mongoid3x.rb → mongoid6x.rb} +3 -3
- data/lib/bullet/notification/n_plus_one_query.rb +3 -3
- data/lib/bullet/notification/unused_eager_loading.rb +12 -7
- data/lib/bullet/rack.rb +6 -1
- data/lib/bullet/version.rb +1 -1
- data/spec/bullet/notification/n_plus_one_query_spec.rb +3 -3
- data/spec/bullet/notification/unused_eager_loading_spec.rb +1 -1
- data/spec/integration/counter_cache_spec.rb +7 -0
- data/test.sh +1 -10
- data/update.sh +1 -10
- metadata +4 -18
- data/Gemfile.mongoid-2.5 +0 -15
- data/Gemfile.mongoid-2.6 +0 -15
- data/Gemfile.mongoid-2.7 +0 -15
- data/Gemfile.mongoid-2.8 +0 -15
- data/Gemfile.mongoid-3.0 +0 -15
- data/Gemfile.mongoid-3.1 +0 -15
- data/Gemfile.rails-3.0 +0 -16
- data/Gemfile.rails-3.1 +0 -16
- data/Gemfile.rails-3.2 +0 -16
- data/lib/bullet/active_record3.rb +0 -233
- data/lib/bullet/active_record3x.rb +0 -205
- data/lib/bullet/mongoid2x.rb +0 -56
- data/spec/integration/active_record3/association_spec.rb +0 -745
data/lib/bullet/mongoid2x.rb
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
module Bullet
|
|
2
|
-
module Mongoid
|
|
3
|
-
def self.enable
|
|
4
|
-
require 'mongoid'
|
|
5
|
-
|
|
6
|
-
::Mongoid::Contexts::Mongo.class_eval do
|
|
7
|
-
alias_method :origin_first, :first
|
|
8
|
-
alias_method :origin_last, :last
|
|
9
|
-
alias_method :origin_iterate, :iterate
|
|
10
|
-
alias_method :origin_eager_load, :eager_load
|
|
11
|
-
|
|
12
|
-
def first
|
|
13
|
-
result = origin_first
|
|
14
|
-
Bullet::Detector::NPlusOneQuery.add_impossible_object(result) if result
|
|
15
|
-
result
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def last
|
|
19
|
-
result = origin_last
|
|
20
|
-
Bullet::Detector::NPlusOneQuery.add_impossible_object(result) if result
|
|
21
|
-
result
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def iterate(&block)
|
|
25
|
-
records = execute.to_a
|
|
26
|
-
if records.size > 1
|
|
27
|
-
Bullet::Detector::NPlusOneQuery.add_possible_objects(records)
|
|
28
|
-
elsif records.size == 1
|
|
29
|
-
Bullet::Detector::NPlusOneQuery.add_impossible_object(records.first)
|
|
30
|
-
end
|
|
31
|
-
origin_iterate(&block)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def eager_load(docs)
|
|
35
|
-
associations = criteria.inclusions.map(&:name)
|
|
36
|
-
docs.each do |doc|
|
|
37
|
-
Bullet::Detector::Association.add_object_associations(doc, associations)
|
|
38
|
-
end
|
|
39
|
-
Bullet::Detector::UnusedEagerLoading.add_eager_loadings(docs, associations)
|
|
40
|
-
origin_eager_load(docs)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
::Mongoid::Relations::Accessors.class_eval do
|
|
45
|
-
alias_method :origin_set_relation, :set_relation
|
|
46
|
-
|
|
47
|
-
def set_relation(name, relation)
|
|
48
|
-
if relation && relation.metadata.macro !~ /embed/
|
|
49
|
-
Bullet::Detector::NPlusOneQuery.call_association(self, name)
|
|
50
|
-
end
|
|
51
|
-
origin_set_relation(name, relation)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|