bullet 5.8.1 → 5.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ae0cc579f8e882c40e1e244ba991acc79bac497
4
- data.tar.gz: '0558ed3107fd121dbf1ced92c20ef49609b0cc8d'
3
+ metadata.gz: fefb038c3c46f100cc22cdd95c417c781aff2943
4
+ data.tar.gz: ad23b5755c4956788bad2b3ae98323d6e24c2bb8
5
5
  SHA512:
6
- metadata.gz: '019773e310b70aac51bb012d173c4354a8224f4808dcedbd1d0d58180faec7dc2738b78e15e14fe8a632a60a89f8423aea0fb9875feac28ca36c756235612bee'
7
- data.tar.gz: fe9a9caf06ff5daea8090187c551b35b983ba7d136d37f579ecdccdfab7e11b26fc989ac58e8df5b672ae20ab4931abcac014e03fefd024bab135d04a6412b1a
6
+ metadata.gz: 79f4e0bb1d4e62df6460fd668f0789936e3e0b1c36d078bb13ec2788f9d69f46e0dd3615e1983019bc4c83d6e7d2b2195377c5216a23038d270aee2ddfb6e77c
7
+ data.tar.gz: 504905ca503f0727e71c1c476ab058eab57618bc6a4a9084411c479ebd63913c75ac178cf27566d05e800887e1d6f1e709aa89733632743c7216db810d410fb8
@@ -1,8 +1,9 @@
1
1
  ## Next Release
2
2
 
3
- ## 5.8.1
3
+ ## 5.9.0 (11/11/2018)
4
4
 
5
5
  * Require Ruby 2.3+
6
+ * Support Mongo 7.x
6
7
 
7
8
  ## 5.8.0 (10/29/2018)
8
9
 
@@ -0,0 +1,15 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '~> 5.0'
6
+ gem 'sqlite3', platforms: [:ruby]
7
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
+ gem 'mongoid', '~> 7.0.0'
9
+
10
+ gem "rspec"
11
+
12
+ platforms :rbx do
13
+ gem 'rubysl', '~> 2.0'
14
+ gem 'rubinius-developer_tools'
15
+ end
@@ -42,6 +42,8 @@ module Bullet
42
42
  'mongoid5x'
43
43
  elsif mongoid6x?
44
44
  'mongoid6x'
45
+ elsif mongoid7x?
46
+ 'mongoid7x'
45
47
  else
46
48
  raise "Bullet does not support mongoid #{::Mongoid::VERSION} yet"
47
49
  end
@@ -91,5 +93,9 @@ module Bullet
91
93
  def mongoid6x?
92
94
  mongoid? && ::Mongoid::VERSION =~ /\A6/
93
95
  end
96
+
97
+ def mongoid7x?
98
+ mongoid? && ::Mongoid::VERSION =~ /\A7/
99
+ end
94
100
  end
95
101
  end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bullet
4
+ module Mongoid
5
+ def self.enable
6
+ require 'mongoid'
7
+ ::Mongoid::Contextual::Mongo.class_eval do
8
+ alias_method :origin_first, :first
9
+ alias_method :origin_last, :last
10
+ alias_method :origin_each, :each
11
+ alias_method :origin_eager_load, :eager_load
12
+
13
+ def first(opts = {})
14
+ result = origin_first(opts)
15
+ Bullet::Detector::NPlusOneQuery.add_impossible_object(result) if result
16
+ result
17
+ end
18
+
19
+ def last(opts = {})
20
+ result = origin_last(opts)
21
+ Bullet::Detector::NPlusOneQuery.add_impossible_object(result) if result
22
+ result
23
+ end
24
+
25
+ def each(&block)
26
+ return to_enum unless block_given?
27
+
28
+ records = []
29
+ origin_each { |record| records << record }
30
+ if records.length > 1
31
+ Bullet::Detector::NPlusOneQuery.add_possible_objects(records)
32
+ elsif records.size == 1
33
+ Bullet::Detector::NPlusOneQuery.add_impossible_object(records.first)
34
+ end
35
+ records.each(&block)
36
+ end
37
+
38
+ def eager_load(docs)
39
+ associations = criteria.inclusions.map(&:name)
40
+ docs.each do |doc|
41
+ Bullet::Detector::NPlusOneQuery.add_object_associations(doc, associations)
42
+ end
43
+ Bullet::Detector::UnusedEagerLoading.add_eager_loadings(docs, associations)
44
+ origin_eager_load(docs)
45
+ end
46
+ end
47
+
48
+ ::Mongoid::Association::Accessors.class_eval do
49
+ alias_method :origin_get_relation, :get_relation
50
+
51
+ def get_relation(name, association, object, reload = false)
52
+ result = origin_get_relation(name, association, object, reload)
53
+ unless association.embedded?
54
+ Bullet::Detector::NPlusOneQuery.call_association(self, name)
55
+ end
56
+ result
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bullet
4
- VERSION = '5.8.1'
4
+ VERSION = '5.9.0'
5
5
  end
data/test.sh CHANGED
@@ -6,6 +6,7 @@ BUNDLE_GEMFILE=Gemfile.rails-5.0 bundle && BUNDLE_GEMFILE=Gemfile.rails-5.0 bund
6
6
  BUNDLE_GEMFILE=Gemfile.rails-4.2 bundle && BUNDLE_GEMFILE=Gemfile.rails-4.2 bundle exec rspec spec
7
7
  BUNDLE_GEMFILE=Gemfile.rails-4.1 bundle && BUNDLE_GEMFILE=Gemfile.rails-4.1 bundle exec rspec spec
8
8
  BUNDLE_GEMFILE=Gemfile.rails-4.0 bundle && BUNDLE_GEMFILE=Gemfile.rails-4.0 bundle exec rspec spec
9
+ BUNDLE_GEMFILE=Gemfile.mongoid-7.0 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-7.0 bundle exec rspec spec
9
10
  BUNDLE_GEMFILE=Gemfile.mongoid-6.0 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-6.0 bundle exec rspec spec
10
11
  BUNDLE_GEMFILE=Gemfile.mongoid-5.0 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-5.0 bundle exec rspec spec
11
12
  BUNDLE_GEMFILE=Gemfile.mongoid-4.0 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-4.0 bundle exec rspec spec
data/update.sh CHANGED
@@ -4,6 +4,7 @@ BUNDLE_GEMFILE=Gemfile.rails-5.0 bundle update
4
4
  BUNDLE_GEMFILE=Gemfile.rails-4.2 bundle update
5
5
  BUNDLE_GEMFILE=Gemfile.rails-4.1 bundle update
6
6
  BUNDLE_GEMFILE=Gemfile.rails-4.0 bundle update
7
+ BUNDLE_GEMFILE=Gemfile.mongoid-7.0 bundle update
7
8
  BUNDLE_GEMFILE=Gemfile.mongoid-6.0 bundle update
8
9
  BUNDLE_GEMFILE=Gemfile.mongoid-5.0 bundle update
9
10
  BUNDLE_GEMFILE=Gemfile.mongoid-4.0 bundle update
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.8.1
4
+ version: 5.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-30 00:00:00.000000000 Z
11
+ date: 2018-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -54,6 +54,7 @@ files:
54
54
  - Gemfile.mongoid-4.0
55
55
  - Gemfile.mongoid-5.0
56
56
  - Gemfile.mongoid-6.0
57
+ - Gemfile.mongoid-7.0
57
58
  - Gemfile.rails-4.0
58
59
  - Gemfile.rails-4.1
59
60
  - Gemfile.rails-4.2
@@ -84,6 +85,7 @@ files:
84
85
  - lib/bullet/mongoid4x.rb
85
86
  - lib/bullet/mongoid5x.rb
86
87
  - lib/bullet/mongoid6x.rb
88
+ - lib/bullet/mongoid7x.rb
87
89
  - lib/bullet/notification.rb
88
90
  - lib/bullet/notification/base.rb
89
91
  - lib/bullet/notification/counter_cache.rb