deferring 0.7.0 → 0.7.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.
- checksums.yaml +4 -4
- data/lib/deferring/deferred_association.rb +6 -2
- data/lib/deferring/version.rb +1 -1
- data/spec/lib/deferring_has_many_spec.rb +5 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14441d2a2db2d40728af34eb27b47b4da1c7961a716be04a10019468298f7cfc
|
4
|
+
data.tar.gz: ddef46c10b1d7fd9f6e44a1f2e5507937c85e42af8424bc8f2d5d96e156de96a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54eedbbfc6be7e60b517e38a94c1b0b248dd55e52ef90036ea17e4148c92ccf0b37ed153732e28601368704a238ec8dc9178cf7eacf3cacf3af180306bf6a0a4
|
7
|
+
data.tar.gz: 4c2f00b244eb1cab289353e5abcb46cdd48e58e656c83dbc5316af84ad826fb20d0974acd57ff5e90e78656044ce0cb800c9f84e87fc4bd8a36065433b0b01b8
|
@@ -62,8 +62,12 @@ module Deferring
|
|
62
62
|
#
|
63
63
|
# The delegation has to be explicit in this case, because the inclusion of
|
64
64
|
# Enumerable also defines the count-method on DeferredAssociation.
|
65
|
-
def count(*args)
|
66
|
-
|
65
|
+
def count(*args, &block)
|
66
|
+
if block_given?
|
67
|
+
objects.count(*args, &block)
|
68
|
+
else
|
69
|
+
original_association.count(*args)
|
70
|
+
end
|
67
71
|
end
|
68
72
|
|
69
73
|
# Delegates Ruby's Enumerable#select method to the original association when
|
data/lib/deferring/version.rb
CHANGED
@@ -375,6 +375,11 @@ RSpec.describe 'deferred has_many associations' do
|
|
375
375
|
expect { person.issues.to_a }.to query(0)
|
376
376
|
expect { person.issues.count }.to query(1) { |sql| expect(sql).to include('SELECT COUNT(*) FROM "issues"') }
|
377
377
|
end
|
378
|
+
|
379
|
+
it 'should execute count with a block' do
|
380
|
+
person = Person.where(name: 'Bob').first
|
381
|
+
expect(person.issues.count { |i| i.subject.start_with?('Printer') }).to eq(1)
|
382
|
+
end
|
378
383
|
end
|
379
384
|
|
380
385
|
describe 'size' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deferring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robin Roestenburg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -141,8 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
|
-
|
145
|
-
rubygems_version: 2.7.6.2
|
144
|
+
rubygems_version: 3.1.4
|
146
145
|
signing_key:
|
147
146
|
specification_version: 4
|
148
147
|
summary: Defer saving ActiveRecord associations until parent is saved
|