deferring 0.7.0 → 0.7.1

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: 35b9b80d6c94a8b980f80cd953565bcf7cf2f8a207de3880904286e617ed30a0
4
- data.tar.gz: f78c5caa4d9c1a5a446ac504c839bebf21e29a059e57e5739de4ef5842106b63
3
+ metadata.gz: 14441d2a2db2d40728af34eb27b47b4da1c7961a716be04a10019468298f7cfc
4
+ data.tar.gz: ddef46c10b1d7fd9f6e44a1f2e5507937c85e42af8424bc8f2d5d96e156de96a
5
5
  SHA512:
6
- metadata.gz: af8785f36ce8551ba95a9f7dab9d28fdfc8cd46bc6a427bddc70007985225ce3edd23daf1c1cdd21f5102d1c3bef0d2a0ae2598752b0fa38318225235db8a9e4
7
- data.tar.gz: 549c445412012809bdbe613dd028395acc22ef4dc5e26fc803fc2db5734a2f7b26fc4c134693c6fae5147e6bb7d83d7b4afde8eed25719ef57ea47af3232c4d5
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
- original_association.count(*args)
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
@@ -1,3 +1,3 @@
1
1
  module Deferring
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
@@ -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.0
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-14 00:00:00.000000000 Z
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
- rubyforge_project:
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