mongoid-locker 2.0.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83a2fc5d9474fb911afd4cb106587e84aa7209ee8875b578feaabdff226c3be1
4
- data.tar.gz: 8bdfc514dd4649646ea3de44ebf0892b6b9b74a83aadffd5d2c5694177842ba6
3
+ metadata.gz: 81cc5f3f7114bc807ad56afade38745fb74d2d4ed45eb007a12b0e61a0237450
4
+ data.tar.gz: 81ba6e72064c31a302ffcbfd0a6df6c555051057d2b8890b696ef3b62d033baa
5
5
  SHA512:
6
- metadata.gz: fdd9b3d0ad671dd6b2bbf862f47cb7b642446d2f8642861de0d755ee7143e61eb60e3a3f6614f235ed79c09085ff408c4f1a4f39707379c358e655748229866c
7
- data.tar.gz: 2cb5ec0046da6f2d6f7b58e8bac93ea6297da9ae3279281b68b0528ebe527b0e6b928db29a280e3282e19c34d16b1e289e6947ab45f1bf33c70bf6864ccc4c9d
6
+ metadata.gz: 75b674da45761991d07da697139454f53864327d9b3f0a73b20e5d5a278f1faabce95430c3cfc7e06ff2597a5be4acccb4c714b66d2ec17b0b93ef270c934a5e
7
+ data.tar.gz: 402ab3c14985c52c65b4440c7b763d8b59ccf1f9e33cd97b7324f237353443edd96e9134031ee15735213ed1d19cf8865151f05a0e32dd12d8ce43f3c3e4f04e
@@ -0,0 +1,71 @@
1
+ name: Test
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ entry:
12
+ - { ruby: '2.6.6', mongo: 'mongo:4.4', mongoid: '5' }
13
+ - { ruby: 'jruby-9.1.17.0', mongo: 'mongo:4.4', mongoid: '5' }
14
+ - { ruby: 'jruby-9.2.11.1', mongo: 'mongo:4.4', mongoid: '5' }
15
+ - { ruby: '2.6.6', mongo: 'mongo:4.4', mongoid: '6' }
16
+ - { ruby: '2.7.1', mongo: 'mongo:4.4', mongoid: '6' }
17
+ - { ruby: '3.0.5', mongo: 'mongo:4.4', mongoid: '6' }
18
+ - { ruby: '3.1.3', mongo: 'mongo:4.4', mongoid: '6' }
19
+ - { ruby: 'jruby-9.2.11.1', mongo: 'mongo:4.4', mongoid: '6' }
20
+ - { ruby: '2.6.6', mongo: 'mongo:4.4', mongoid: '7', coverage: 'true' }
21
+ - { ruby: '2.7.1', mongo: 'mongo:4.4', mongoid: '7' }
22
+ - { ruby: '3.0.5', mongo: 'mongo:4.4', mongoid: '7' }
23
+ - { ruby: '3.1.3', mongo: 'mongo:4.4', mongoid: '7' }
24
+ - { ruby: 'jruby-9.2.11.1', mongo: 'mongo:4.4', mongoid: '7' }
25
+ - { ruby: '2.6.6', mongo: 'mongo:4.4', mongoid: '8' }
26
+ - { ruby: '2.7.1', mongo: 'mongo:4.4', mongoid: '8' }
27
+ - { ruby: '3.0.5', mongo: 'mongo:4.4', mongoid: '8' }
28
+ - { ruby: '3.1.3', mongo: 'mongo:4.4', mongoid: '8' }
29
+ experimental: [false]
30
+
31
+ name: test (ruby=${{ matrix.entry.ruby }}, mongo=${{ matrix.entry.mongo }}, mongoid=${{ matrix.entry.mongoid }})
32
+ runs-on: ubuntu-latest
33
+
34
+ continue-on-error: ${{ matrix.experimental }}
35
+
36
+ services:
37
+ mongo:
38
+ image: ${{ matrix.entry.mongo }}
39
+ ports: ["27017:27017"]
40
+
41
+ env:
42
+ MONGOID_VERSION: ${{ matrix.entry.mongoid }}
43
+ COVERAGE: ${{ matrix.entry.coverage }}
44
+
45
+ steps:
46
+ - uses: actions/checkout@v2
47
+
48
+ - name: Set up Ruby
49
+ uses: ruby/setup-ruby@v1
50
+ with:
51
+ ruby-version: ${{ matrix.entry.ruby }}
52
+ bundler-cache: true
53
+
54
+ - name: Checks
55
+ if: ${{ matrix.entry.coverage == 'true' }}
56
+ run: |
57
+ bundle exec rubocop
58
+ # Disabled until mongoid-danger is updated to support Github Actions
59
+ # bundle exec danger
60
+
61
+ - name: Run tests
62
+ run: bundle exec rspec
63
+
64
+ - name: Code Climate
65
+ if: ${{ env.CC_TEST_REPORTER_ID != '' && success() && matrix.entry.coverage == 'true' }}
66
+ run: |
67
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter;
68
+ chmod +x ./cc-test-reporter;
69
+ ./cc-test-reporter before-build;
70
+ ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.json coverage/.resultset.json;
71
+ ./cc-test-reporter upload-coverage;
data/.rubocop.yml CHANGED
@@ -1,2 +1,24 @@
1
+ Lint/RaiseException:
2
+ Enabled: true
3
+
4
+ Lint/StructNewOverride:
5
+ Enabled: true
6
+
7
+ Style/HashEachMethods:
8
+ Enabled: true
9
+
10
+ Style/HashTransformKeys:
11
+ Enabled: true
12
+
13
+ Style/HashTransformValues:
14
+ Enabled: true
15
+
16
+ RSpec/MultipleExpectations:
17
+ Enabled: false
18
+
19
+ RSpec/LeakyConstantDeclaration:
20
+ Enabled: false
21
+
1
22
  inherit_from: .rubocop_todo.yml
23
+
2
24
  require: rubocop-rspec
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-10-23 10:17:29 -0400 using RuboCop version 0.75.1.
3
+ # on 2020-04-07 15:05:45 -0400 using RuboCop version 0.81.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -14,14 +14,15 @@ Bundler/DuplicatedGem:
14
14
  - 'Gemfile'
15
15
 
16
16
  # Offense count: 4
17
+ # Configuration parameters: IgnoredMethods.
17
18
  Metrics/AbcSize:
18
- Max: 21
19
+ Max: 24
19
20
 
20
- # Offense count: 10
21
+ # Offense count: 11
21
22
  # Configuration parameters: CountComments, ExcludedMethods.
22
23
  # ExcludedMethods: refine
23
24
  Metrics/BlockLength:
24
- Max: 292
25
+ Max: 290
25
26
 
26
27
  # Offense count: 5
27
28
  # Configuration parameters: CountComments, ExcludedMethods.
@@ -31,7 +32,7 @@ Metrics/MethodLength:
31
32
  # Offense count: 1
32
33
  # Configuration parameters: CountComments.
33
34
  Metrics/ModuleLength:
34
- Max: 104
35
+ Max: 105
35
36
 
36
37
  # Offense count: 2
37
38
  # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
@@ -42,30 +43,35 @@ Naming/FileName:
42
43
  - 'spec/mongoid-locker_spec.rb'
43
44
 
44
45
  # Offense count: 1
45
- # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
46
+ # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
46
47
  # NamePrefix: is_, has_, have_
47
- # NamePrefixBlacklist: is_, has_, have_
48
- # NameWhitelist: is_a?
48
+ # ForbiddenPrefixes: is_, has_, have_
49
+ # AllowedMethods: is_a?
49
50
  # MethodDefinitionMacros: define_method, define_singleton_method
50
51
  Naming/PredicateName:
51
52
  Exclude:
52
53
  - 'spec/**/*'
53
54
  - 'lib/mongoid/locker.rb'
54
55
 
55
- # Offense count: 12
56
- # Configuration parameters: Prefixes.
57
- # Prefixes: when, with, without
58
- RSpec/ContextWording:
56
+ # Offense count: 2
57
+ RSpec/BeforeAfterAll:
58
+ Exclude:
59
+ - 'spec/spec_helper.rb'
60
+ - 'spec/rails_helper.rb'
61
+ - 'spec/support/**/*.rb'
62
+ - 'spec/test_examples_spec.rb'
63
+
64
+ # Offense count: 1
65
+ RSpec/DescribeClass:
59
66
  Exclude:
60
- - 'spec/support/configurations_shared_context.rb'
61
- - 'spec/support/populate_database_shared_context.rb'
62
- - 'spec/support/reset_shared_context.rb'
67
+ - 'spec/test_examples_spec.rb'
63
68
 
64
- # Offense count: 7
69
+ # Offense count: 8
65
70
  # Configuration parameters: Max.
66
71
  RSpec/ExampleLength:
67
72
  Exclude:
68
73
  - 'spec/support/locker_is_included_shared_examples.rb'
74
+ - 'spec/test_examples_spec.rb'
69
75
 
70
76
  # Offense count: 1
71
77
  # Configuration parameters: CustomTransform, IgnoreMethods.
@@ -73,21 +79,16 @@ RSpec/FilePath:
73
79
  Exclude:
74
80
  - 'spec/mongoid-locker_spec.rb'
75
81
 
76
- # Offense count: 5
77
- RSpec/LeakyConstantDeclaration:
78
- Exclude:
79
- - 'spec/support/configurations_shared_context.rb'
80
-
81
82
  # Offense count: 12
82
83
  # Configuration parameters: .
83
84
  # SupportedStyles: have_received, receive
84
85
  RSpec/MessageSpies:
85
86
  EnforcedStyle: receive
86
87
 
87
- # Offense count: 11
88
- # Configuration parameters: AggregateFailuresByDefault.
89
- RSpec/MultipleExpectations:
90
- Max: 3
88
+ # Offense count: 1
89
+ RSpec/SubjectStub:
90
+ Exclude:
91
+ - 'spec/support/delegated_methods_shared_examples.rb'
91
92
 
92
93
  # Offense count: 2
93
94
  Style/Documentation:
@@ -105,9 +106,9 @@ Style/NumericPredicate:
105
106
  - 'spec/**/*'
106
107
  - 'lib/mongoid/locker.rb'
107
108
 
108
- # Offense count: 33
109
+ # Offense count: 35
109
110
  # Cop supports --auto-correct.
110
111
  # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
111
112
  # URISchemes: http, https
112
- Metrics/LineLength:
113
+ Layout/LineLength:
113
114
  Max: 250
data/.travis.yml CHANGED
@@ -1,48 +1,16 @@
1
- services:
2
- - mongodb
3
-
4
1
  language: ruby
5
2
 
6
3
  cache: bundler
7
4
 
8
- script:
9
- - bundle exec rspec
10
-
11
5
  rvm:
12
- - 2.3.8
13
- - 2.4.5
14
- - 2.5.4
15
- - 2.6.2
16
- - jruby-9.1.17.0
17
- - jruby-9.2.6.0
6
+ - 2.6.6
18
7
 
19
8
  env:
20
- - MONGOID_VERSION=5
21
- - MONGOID_VERSION=6
22
9
  - MONGOID_VERSION=7
23
10
 
24
- matrix:
25
- include:
26
- - rvm: 2.6.2
27
- env:
28
- - MONGOID_VERSION=7
29
- - COVERAGE=true
30
- before_script:
31
- - bundle exec rubocop
32
- - bundle exec danger
33
- after_script:
34
- - if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then
35
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter;
36
- chmod +x ./cc-test-reporter;
37
- ./cc-test-reporter before-build;
38
- ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.json coverage/.resultset.json;
39
- ./cc-test-reporter upload-coverage;
40
- fi
41
- - rvm: ruby-head
42
- - rvm: jruby-head
43
- fast_finish: true
44
- allow_failures:
45
- - rvm: ruby-head
46
- - rvm: jruby-head
11
+ before_script:
12
+ - bundle exec danger
13
+
14
+ script:
15
+ - echo SKIP
47
16
 
48
- bundler_args: --without development
data/CHANGELOG.md CHANGED
@@ -1,21 +1,35 @@
1
1
  ## Changelog
2
2
 
3
+ ### 2.0.2 (2023-01-24)
4
+
5
+ * [#92](https://github.com/mongoid/mongoid-locker/pull/92): Removed TTL and updated unique index definitions - [@cesarizu](https://github.com/cesarizu).
6
+ * [#96](https://github.com/mongoid/mongoid-locker/pull/96): `new Date()` replaced by `Time.now.utc` - [@rsosag](https://github.com/rsosag).
7
+ * [#96](https://github.com/mongoid/mongoid-locker/pull/96): Update the use of the `change` method in tests - [@rsosag](https://github.com/rsosag).
8
+ * [#97](https://github.com/mongoid/mongoid-locker/pull/97): Added support for mongoid 8.0.x versions - [@randikabanura](https://github.com/randikabanura).
9
+
10
+ ### 2.0.1 (2020-06-17)
11
+
12
+ * [#86](https://github.com/mongoid/mongoid-locker/pull/86): Upgraded to RuboCop 0.81.0 - [@dks17](https://github.com/dks17).
13
+ * [#86](https://github.com/mongoid/mongoid-locker/pull/86): Fixed issue with `ruby` `delegate` method - [@dks17](https://github.com/dks17).
14
+ * [#86](https://github.com/mongoid/mongoid-locker/pull/86): Updated Ruby and JRUby versions for Travis config - [@dks17](https://github.com/dks17).
15
+ * [#88](https://github.com/mongoid/mongoid-locker/pull/88): Added RSpec test examples - [@dks17](https://github.com/dks17).
16
+
3
17
  ### 2.0.0 (2019-10-23)
4
18
 
5
- * [#79](https://github.com/mongoid/mongoid-locker/pull/79): Update find_and_lock and find_and_unlock methods - [@dks17](https://github.com/dks17).
6
- * [#78](https://github.com/mongoid/mongoid-locker/pull/78): Upgrade to v2.0 - [@dks17](https://github.com/dks17).
19
+ * [#79](https://github.com/mongoid/mongoid-locker/pull/79): Updated find_and_lock and find_and_unlock methods - [@dks17](https://github.com/dks17).
20
+ * [#78](https://github.com/mongoid/mongoid-locker/pull/78): Upgraded to v2.0 - [@dks17](https://github.com/dks17).
7
21
  * [#83](https://github.com/mongoid/mongoid-locker/pull/83): Upgraded to RuboCop 0.75.1 - [@dblock](https://github.com/dblock).
8
22
 
9
23
  ### 1.0.1 (2019-03-23)
10
24
 
11
- * [#74](https://github.com/mongoid/mongoid-locker/pull/74): Add JRuby tests - [@dks17](https://github.com/dks17).
25
+ * [#74](https://github.com/mongoid/mongoid-locker/pull/74): Added JRuby tests - [@dks17](https://github.com/dks17).
12
26
  * [#68](https://github.com/mongoid/mongoid-locker/pull/68): Fix Rubocop offenses, refactoring, update `ruby` versions, add `COVERAGE` test env, update `.travis.yml` matrix - [@dks17](https://github.com/dks17).
13
- * [#67](https://github.com/mongoid/mongoid-locker/pull/67): Deprecate `:wait` in favor of `:retries` option, which can attempt to grab a lock multiple times - [@afeld](https://github.com/afeld), [@dks17](https://github.com/dks17).
27
+ * [#67](https://github.com/mongoid/mongoid-locker/pull/67): Deprecated `:wait` in favor of `:retries` option, which can attempt to grab a lock multiple times - [@afeld](https://github.com/afeld), [@dks17](https://github.com/dks17).
14
28
  * [#66](https://github.com/mongoid/mongoid-locker/pull/66): Fix Mongoid::Locker::LockError for not persisted document - [@dks17](https://github.com/dks17).
15
- * [#65](https://github.com/mongoid/mongoid-locker/pull/65): Drop `mongoid-compatibility` gem dependency - [@dks17](https://github.com/dks17).
29
+ * [#65](https://github.com/mongoid/mongoid-locker/pull/65): Dropped `mongoid-compatibility` gem dependency - [@dks17](https://github.com/dks17).
16
30
  * [#64](https://github.com/mongoid/mongoid-locker/pull/64): Exclude demo files from the gem - [@dks17](https://github.com/dks17).
17
- * [#60](https://github.com/mongoid/mongoid-locker/pull/60): Drop support for `mongoid` version `2` and `3` - [@dks17](https://github.com/dks17).
18
- * [#60](https://github.com/mongoid/mongoid-locker/pull/60): Add SimpleCov - [@dks17](https://github.com/dks17).
31
+ * [#60](https://github.com/mongoid/mongoid-locker/pull/60): Dropped support for `mongoid` version `2` and `3` - [@dks17](https://github.com/dks17).
32
+ * [#60](https://github.com/mongoid/mongoid-locker/pull/60): Added SimpleCov - [@dks17](https://github.com/dks17).
19
33
 
20
34
  ### 1.0.0 (2018-09-02)
21
35
 
data/Gemfile CHANGED
@@ -4,6 +4,8 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  case ENV['MONGOID_VERSION']
7
+ when /^8/
8
+ gem 'mongoid', '~> 8.0'
7
9
  when /^7/
8
10
  gem 'mongoid', '~> 7.0'
9
11
  when /^6/
@@ -23,9 +25,10 @@ end
23
25
  group :development, :test do
24
26
  gem 'pry-byebug', platforms: :mri
25
27
 
28
+ gem 'mongoid-compatibility'
26
29
  gem 'mongoid-danger', '~> 0.1.1'
27
- gem 'rspec', '~> 3.8'
28
- gem 'rubocop', '0.75.1'
29
- gem 'rubocop-rspec'
30
+ gem 'rspec', '~> 3.9'
31
+ gem 'rubocop', '0.81.0'
32
+ gem 'rubocop-rspec', '1.38.1'
30
33
  gem 'simplecov', require: false
31
34
  end
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Mongoid-Locker
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/mongoid-locker.svg)](https://badge.fury.io/rb/mongoid-locker)
4
+ [![Test Status](https://github.com/mongoid/mongoid-locker/workflows/Test/badge.svg)](https://github.com/mongoid/mongoid-locker/actions)
4
5
  [![Build Status](https://travis-ci.org/mongoid/mongoid-locker.svg?branch=master)](https://travis-ci.org/mongoid/mongoid-locker)
5
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/04ee4ee75ff54659300a/maintainability)](https://codeclimate.com/github/mongoid/mongoid-locker/maintainability)
6
7
  [![Test Coverage](https://api.codeclimate.com/v1/badges/04ee4ee75ff54659300a/test_coverage)](https://codeclimate.com/github/mongoid/mongoid-locker/test_coverage)
@@ -11,12 +12,12 @@ Document-level optimistic locking for MongoDB via Mongoid. Mongoid-Locker is an
11
12
 
12
13
  **NOTE:** Please refer to [1-x-stable](https://github.com/mongoid/mongoid-locker/tree/1-x-stable) branch for `1.x.x` documentation. See the [UPGRADING](UPGRADING.md) guide and [CHANGELOG](CHANGELOG.md) for an overview of the changes.
13
14
 
14
- [Tested](https://travis-ci.org/mongoid/mongoid-locker) against:
15
- - MRI: `2.3.8`, `2.4.5`, `2.5.4`, `2.6.2`
16
- - JRuby `9.1.17.0`, `9.2.6.0`
17
- - Mongoid: `5`, `6`, `7`
15
+ [Tested](https://github.com/mongoid/mongoid-locker/actions) against:
16
+ - MRI: `2.3.8`, `2.4.7`, `2.5.7`, `2.6.6`, `2.7.1`, `3.0.5`, `3.1.3`
17
+ - JRuby `9.1.17.0`, `9.2.11.1`
18
+ - Mongoid: `5`, `6`, `7`, `8`
18
19
 
19
- See [.travis.yml](.travis.yml) for the latest test matrix.
20
+ See [.github/workflows/test.yml](.github/workflows/test.yml) for the latest test matrix.
20
21
 
21
22
  ## Usage
22
23
 
@@ -37,8 +38,6 @@ class User
37
38
  field :locked_at, type: Time
38
39
 
39
40
  field :age, type: Integer
40
-
41
- index({ _id: 1, locking_name: 1 }, name: 'mongoid_locker_index', sparse: true, unique: true, expire_after_seconds: lock_timeout)
42
41
  end
43
42
  ```
44
43
 
@@ -155,8 +154,11 @@ class User
155
154
  end
156
155
  ```
157
156
 
157
+ ## Testing with RSpec
158
+ Please see examples in [test_examples_spec.rb](spec/test_examples_spec.rb) file.
159
+
158
160
  ## Copyright & License
159
161
 
160
- Copyright (c) 2012-2019 Aidan Feldman & Contributors
162
+ Copyright (c) 2012-2020 Aidan Feldman & Contributors
161
163
 
162
164
  MIT License, see [LICENSE](LICENSE.txt) for more information.
data/RELEASING.md CHANGED
@@ -12,7 +12,7 @@ bundle install
12
12
  bundle exec rake
13
13
  ```
14
14
 
15
- Check that the last build succeeded in [Travis CI](https://travis-ci.org/mongoid/mongoid-locker) for all supported platforms.
15
+ Check that the last build succeeded in [GitHub Actions](https://github.com/mongoid/mongoid-locker/actions) for all supported platforms.
16
16
 
17
17
  Check the version, if needed modify [lib/mongoid/locker/version.rb](lib/mongoid/locker/version.rb).
18
18
 
@@ -8,7 +8,7 @@ module Mongoid
8
8
  BASE_KEY = 'mongoid.locker.errors.messages'
9
9
 
10
10
  def initialize(key, **params)
11
- message = I18n.translate("#{BASE_KEY}.#{key}.message", params)
11
+ message = I18n.translate("#{BASE_KEY}.#{key}.message", **params)
12
12
 
13
13
  super("\nmessage:\n #{message}")
14
14
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mongoid
4
4
  module Locker
5
- VERSION = '2.0.0'
5
+ VERSION = '2.0.2'
6
6
  end
7
7
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'forwardable'
3
4
  require 'securerandom'
4
5
 
5
6
  module Mongoid
@@ -103,6 +104,8 @@ module Mongoid
103
104
 
104
105
  # @api private
105
106
  def included(klass)
107
+ klass.extend(Forwardable) unless klass.ancestors.include?(Forwardable)
108
+
106
109
  klass.extend ClassMethods
107
110
  klass.singleton_class.instance_eval { attr_accessor(*MODULE_METHODS) }
108
111
 
@@ -114,7 +117,7 @@ module Mongoid
114
117
  klass.backoff_algorithm = backoff_algorithm
115
118
  klass.locking_name_generator = locking_name_generator
116
119
 
117
- klass.delegate(*MODULE_METHODS, to: :class)
120
+ klass.def_delegators(klass, *MODULE_METHODS)
118
121
  klass.singleton_class.delegate(*(methods(false) - MODULE_METHODS.flat_map { |method| [method, "#{method}=".to_sym] } - %i[included reset! configure]), to: self)
119
122
  end
120
123
  end
@@ -135,8 +138,7 @@ module Mongoid
135
138
  where(
136
139
  '$and': [
137
140
  { locking_name_field => { '$exists': true, '$ne': nil } },
138
- { locked_at_field => { '$exists': true, '$ne': nil } },
139
- { '$where': "new Date() - this.#{locked_at_field} < #{lock_timeout * 1000}" }
141
+ { locked_at_field => { '$gte': Time.now.utc - (lock_timeout * 1000) } }
140
142
  ]
141
143
  )
142
144
  end
@@ -165,9 +167,7 @@ module Mongoid
165
167
  { locked_at_field => { '$eq': nil } }
166
168
  ]
167
169
  },
168
- {
169
- '$where': "new Date() - this.#{locked_at_field} >= #{lock_timeout * 1000}"
170
- }
170
+ { locked_at_field => { '$lt': Time.now.utc - (lock_timeout * 1000) } }
171
171
  ]
172
172
  )
173
173
  end
@@ -18,5 +18,5 @@ Gem::Specification.new do |s|
18
18
  s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
19
19
  s.require_paths = ['lib']
20
20
 
21
- s.add_dependency 'mongoid', '>= 5.0', '< 8'
21
+ s.add_dependency 'mongoid', '>= 5.0', '< 9'
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-locker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aidan Feldman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-23 00:00:00.000000000 Z
11
+ date: 2023-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '5.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '8'
22
+ version: '9'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '5.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '8'
32
+ version: '9'
33
33
  description: Allows multiple processes to operate on individual documents in MongoDB
34
34
  while ensuring that only one can act at a time.
35
35
  email:
@@ -38,6 +38,7 @@ executables: []
38
38
  extensions: []
39
39
  extra_rdoc_files: []
40
40
  files:
41
+ - ".github/workflows/test.yml"
41
42
  - ".gitignore"
42
43
  - ".rspec"
43
44
  - ".rubocop.yml"
@@ -79,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
80
  - !ruby/object:Gem::Version
80
81
  version: '0'
81
82
  requirements: []
82
- rubygems_version: 3.0.3
83
+ rubygems_version: 3.0.9
83
84
  signing_key:
84
85
  specification_version: 4
85
86
  summary: Document-level optimistic locking for MongoDB via Mongoid.