mongoid 7.2.4 → 7.2.5

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: 5841b5911599ef45f1b350592ec4995d2a044e723b14ef03e16cf7508449d396
4
- data.tar.gz: c6276353b2e03f57c166c96f7bbcee0362a391f91e19c294a7c76a3c3dad3fe6
3
+ metadata.gz: 48a874132bc5ad122d06af32088dc9d274a7f22be5c103c7ffd4b02e7d7ab665
4
+ data.tar.gz: 295479a0affc8ed42a63765e75fef536d1465a7d35742df6fba76f0d27ae6ae5
5
5
  SHA512:
6
- metadata.gz: 277666610a79f335d47add6f4fb24ecb4a47ea6a245f7d28cec43258876ba469463460a98a1eeeeee5f200a5ab58ed6da7c81dec3be9d617d5ba970194949e09
7
- data.tar.gz: a564a89c548c566a230d03ad69f6323280c071a04f3754f7a2abdeb1da883a4fa6856e7b9e091fdfb0325017f160eb81c875169da54bc04c865e2499f4cd31e9
6
+ metadata.gz: b2ab81319ae56b679033c2dcb6d0f4dbe3324ab38c2e6ded3c3a79a044f3a346162fedd79054f91a97823944fbb2d1e9ac90a301e56135ac7d139a8e4cfdeb04
7
+ data.tar.gz: 02d0cfefc3a885ac256a683112467536f4e0adae1b0c3e216e1dfa34c27137f226fa445ced26e9d02a8d45bd4482af100c491dd83aef9f6ea87d6f4de7653c9f
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/mongoid.rb CHANGED
@@ -6,6 +6,7 @@ require "support/ruby_version"
6
6
  require "forwardable"
7
7
  require "time"
8
8
  require "set"
9
+ require "ruby2_keywords"
9
10
 
10
11
  require "active_support"
11
12
  require "active_support/core_ext"
@@ -415,7 +415,7 @@ module Mongoid
415
415
  # @param [ Proc ] block Optional block to pass.
416
416
  #
417
417
  # @return [ Criteria, Object ] A Criteria or return value from the target.
418
- def method_missing(name, *args, &block)
418
+ ruby2_keywords def method_missing(name, *args, &block)
419
419
  return super if _target.respond_to?(name)
420
420
  klass.send(:with_scope, criteria) do
421
421
  criteria.public_send(name, *args, &block)
@@ -133,7 +133,7 @@ module Mongoid
133
133
  # @param [ String, Symbol ] name The name of the method.
134
134
  # @param [ Array ] args The arguments passed to the method.
135
135
  #
136
- def method_missing(name, *args, &block)
136
+ ruby2_keywords def method_missing(name, *args, &block)
137
137
  _target.send(name, *args, &block)
138
138
  end
139
139
 
@@ -533,7 +533,7 @@ module Mongoid
533
533
  end
534
534
  end
535
535
 
536
- def method_missing(name, *args, &block)
536
+ ruby2_keywords def method_missing(name, *args, &block)
537
537
  entries.send(name, *args, &block)
538
538
  end
539
539
 
@@ -443,7 +443,7 @@ module Mongoid
443
443
  # @return [ Criteria, Object ] A Criteria or return value from the target.
444
444
  #
445
445
  # @since 2.0.0.beta.1
446
- def method_missing(name, *args, &block)
446
+ ruby2_keywords def method_missing(name, *args, &block)
447
447
  if _target.respond_to?(name)
448
448
  _target.send(name, *args, &block)
449
449
  else
@@ -568,7 +568,7 @@ module Mongoid
568
568
  # @return [ Object ] The result of the method call.
569
569
  #
570
570
  # @since 1.0.0
571
- def method_missing(name, *args, &block)
571
+ ruby2_keywords def method_missing(name, *args, &block)
572
572
  if klass.respond_to?(name)
573
573
  klass.send(:with_scope, self) do
574
574
  klass.send(name, *args, &block)
@@ -125,7 +125,7 @@ module Mongoid
125
125
  # @return [ Document ] The document
126
126
  #
127
127
  # @since 2.3.0
128
- def run_callbacks(kind, *args, &block)
128
+ ruby2_keywords def run_callbacks(kind, *args, &block)
129
129
  cascadable_children(kind).each do |child|
130
130
  if child.run_callbacks(child_callback_type(kind, child), *args) == false
131
131
  return false
@@ -2,5 +2,5 @@
2
2
  # encoding: utf-8
3
3
 
4
4
  module Mongoid
5
- VERSION = "7.2.4"
5
+ VERSION = "7.2.5"
6
6
  end
@@ -2449,13 +2449,26 @@ describe Mongoid::Association::Embedded::EmbedsMany::Proxy do
2449
2449
  end
2450
2450
 
2451
2451
  context "when providing a criteria class method" do
2452
+ context "without keyword arguments" do
2452
2453
 
2453
- let(:addresses) do
2454
- person.addresses.california
2454
+ let(:addresses) do
2455
+ person.addresses.california
2456
+ end
2457
+
2458
+ it "applies the criteria to the documents" do
2459
+ expect(addresses).to eq([ address_one ])
2460
+ end
2455
2461
  end
2456
2462
 
2457
- it "applies the criteria to the documents" do
2458
- expect(addresses).to eq([ address_one ])
2463
+ context "with keyword arguments" do
2464
+
2465
+ let(:addresses) do
2466
+ person.addresses.city_and_state(city: "Sacramento", state: "CA")
2467
+ end
2468
+
2469
+ it "applies the criteria to the documents" do
2470
+ expect(addresses).to eq([])
2471
+ end
2459
2472
  end
2460
2473
  end
2461
2474
 
@@ -1332,4 +1332,21 @@ describe Mongoid::Association::Referenced::BelongsTo::Proxy do
1332
1332
  end
1333
1333
  end
1334
1334
  end
1335
+
1336
+ describe "#method_missing" do
1337
+ let!(:person) do
1338
+ Person.create
1339
+ end
1340
+
1341
+ let!(:game) do
1342
+ Game.create(person: person)
1343
+ end
1344
+
1345
+ it 'handles keyword args' do
1346
+ expect do
1347
+ game.person.set_personal_data(ssn: '123', age: 25)
1348
+ end.not_to raise_error
1349
+ end
1350
+
1351
+ end
1335
1352
  end
@@ -141,6 +141,8 @@ describe Mongoid::Clients::Options, retry: 3 do
141
141
  end
142
142
 
143
143
  it 'does not disconnect the original cluster' do
144
+ skip 'https://jira.mongodb.org/browse/MONGOID-5130'
145
+
144
146
  expect(connections_after).to eq(connections_before)
145
147
  expect(cluster_before).to be(cluster_after)
146
148
  end
@@ -3769,10 +3769,14 @@ describe Mongoid::Criteria do
3769
3769
 
3770
3770
  before do
3771
3771
  expect(Person).to receive(:minor).and_call_original
3772
+ expect(Person).to receive(:older_than).and_call_original
3772
3773
  end
3773
3774
 
3774
3775
  it "calls the method on the class" do
3775
3776
  expect(criteria.minor).to be_empty
3777
+ expect do
3778
+ criteria.older_than(age: 25)
3779
+ end.not_to raise_error
3776
3780
  end
3777
3781
  end
3778
3782
 
@@ -78,5 +78,9 @@ class Address
78
78
  def streets
79
79
  all.map(&:street)
80
80
  end
81
+
82
+ def city_and_state(city:, state:)
83
+ where(city: city, state: state)
84
+ end
81
85
  end
82
86
  end
@@ -136,6 +136,10 @@ class Person
136
136
  scope :without_ssn, ->{ without(:ssn) }
137
137
  scope :search, ->(query){ any_of({ title: query }) }
138
138
 
139
+ def self.older_than(age:)
140
+ where(:age.gt => age)
141
+ end
142
+
139
143
  def score_with_rescoring=(score)
140
144
  @rescored = score.to_i + 20
141
145
  self.score_without_rescoring = score
@@ -206,6 +210,11 @@ class Person
206
210
  self.map_with_default["key"] = value
207
211
  end
208
212
 
213
+ def set_personal_data(ssn:, age:)
214
+ self.ssn = ssn
215
+ self.age = age
216
+ end
217
+
209
218
  reset_callbacks(:validate)
210
219
  reset_callbacks(:create)
211
220
  reset_callbacks(:save)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.2.4
4
+ version: 7.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Durran Jordan
@@ -29,7 +29,7 @@ cert_chain:
29
29
  YoFhlyUEi7VLlqNH0H/JFttVZK6+qmLelkVNcIYVLeWOB4Lf4VxEiYGEK1ORxsrY
30
30
  iyYKJJALWY1FAInGRIlvkN+B8o3yIhq1
31
31
  -----END CERTIFICATE-----
32
- date: 2021-07-15 00:00:00.000000000 Z
32
+ date: 2021-08-03 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: activemodel
@@ -71,6 +71,20 @@ dependencies:
71
71
  - - "<"
72
72
  - !ruby/object:Gem::Version
73
73
  version: 3.0.0
74
+ - !ruby/object:Gem::Dependency
75
+ name: ruby2_keywords
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: 0.0.5
81
+ type: :runtime
82
+ prerelease: false
83
+ version_requirements: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: 0.0.5
74
88
  - !ruby/object:Gem::Dependency
75
89
  name: bson
76
90
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file