activerecord-pluck_in_batches 0.1.0 → 0.1.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
  SHA1:
3
- metadata.gz: d70d673d3fcb753581a46b7c95e82cabed118dca
4
- data.tar.gz: 10335c4ceb51cd7d736f9d35447d5948476bd2ff
3
+ metadata.gz: 6e0b5b345ebd97751b243a5f25ea23c62dea6664
4
+ data.tar.gz: 0e24a1ab3dfe73569905b9cb897eac47da67c4e8
5
5
  SHA512:
6
- metadata.gz: 5164054589cbc5ce54522c8d16d81144fdcc7e2b181bcc46dee6f20fa3b7935ef0a32c5ff8e71c174f26184555f440ab6235f0558b88411297de93360b0bc64b
7
- data.tar.gz: b37eedb68b232d51cdf5c7bb302a11479e94ea2248b167be9958c11e2a4b1165eea8d594be3c4af77800a50d542f132453982acfad4fb0dd24c726adb4417fad
6
+ metadata.gz: 323d894d9d44b20564f58eabebfc8f3a68e6916acc911701cae53a933cdf62b55ab627d5c9928074a89d89f43888b16e7250c6fdb83995fdc818f3ef582cb9e2
7
+ data.tar.gz: 8e6062d9b6d4c95cd6807cef84cf4f311100cd6609a10ffa648c9d660566e9e219b5a5ca80f6552a251ceb422b67ccbfc2aa10a3f6f45e39a09ddc0e9b55c0f9
@@ -8,7 +8,7 @@ module PluckInBatches
8
8
  batch.pluck(*args).each(&block)
9
9
  end
10
10
  end
11
-
11
+
12
12
  def in_batches(options = {})
13
13
  options.assert_valid_keys(:batch_size)
14
14
 
@@ -16,11 +16,14 @@ module PluckInBatches
16
16
  batches = (count / batch_size.to_f).ceil
17
17
 
18
18
  relation = reorder("#{quoted_table_name}.#{quoted_primary_key} ASC").limit(batch_size)
19
- batches.times do |i|
20
- yield relation.offset(i * batch_size)
21
- end
22
19
 
23
- nil
20
+ if block_given?
21
+ batches.times do |i|
22
+ yield relation.offset(i * batch_size)
23
+ end
24
+ else
25
+ batches.times.map { |i| relation.offset(i * batch_size) }
26
+ end
24
27
  end
25
28
  end
26
29
 
@@ -1,5 +1,5 @@
1
1
  module Activerecord
2
2
  module PluckInBatches
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-pluck_in_batches
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Lail
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-07 00:00:00.000000000 Z
11
+ date: 2016-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  requirements: []
90
90
  rubyforge_project:
91
- rubygems_version: 2.2.2
91
+ rubygems_version: 2.4.8
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: Like find_each or find_in_batches but for pluck