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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e0b5b345ebd97751b243a5f25ea23c62dea6664
|
4
|
+
data.tar.gz: 0e24a1ab3dfe73569905b9cb897eac47da67c4e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
|
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.
|
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:
|
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.
|
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
|