active_sample 1.0.1 → 1.0.2

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: f1513c164798f757b3fc73c5e68c2f35d05af054
4
- data.tar.gz: a6a0d345d62422af604a2e343c1976e56cd2e5c3
3
+ metadata.gz: 9d10720d2f67b5c169a79f0f2f1a09832a899187
4
+ data.tar.gz: 118738a384f454345565d3d148a88173af9a3d82
5
5
  SHA512:
6
- metadata.gz: beea2ea92ce72d877f58e0ce30f0a4219970d216fc4e8c539756e99d0f16e01aebe2380d7bc6478097e4bc10d0fe52ec8161bc5a2ed53376152b283a8027ddd9
7
- data.tar.gz: 6e11efeb2582aa9b16771b39822f95b0f9e767d36055effd9a6acc74d1551c7b08931a67795b50e9f581c93697ce70c05d51feed37841bccc70dc0d4843675da
6
+ metadata.gz: ce11bf7bf2bd151fc850d2d04c646538a6ae2199b80b3a1f82d9f2ddac43f08686d8949b504dc33ca01e170955136ce212527468951e71dfee0e4912816f8904
7
+ data.tar.gz: 103c0e225d3e17792a63b11eb4d96f7361d0c7f71f192853e2bd0f93b78256bec3d7eef73ae4800e312e5e1222549db1c59ef672e06b371408da8edc76c35dcc
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.2 - 2017.06.28
4
+
5
+ - Add sample support for model's primary key not `:id`
6
+
3
7
  ## 1.0.1 - 2016.05.07
4
8
 
5
9
  - Improves `Model.sample(1)` case.
@@ -10,18 +10,18 @@ module ActiveSample
10
10
  raise NegativeSampleError.new("negative sample number".freeze)
11
11
  end
12
12
 
13
- max_id = maximum(:id)
13
+ max_id = maximum(primary_key)
14
14
 
15
15
  return nil if max_id == nil
16
16
 
17
17
  if n == 1
18
- while !(found = find_by(id: 1 + rand(max_id))); end
18
+ while !(found = find_by(primary_key => 1 + rand(max_id))); end
19
19
 
20
20
  found
21
21
  elsif n == 0
22
22
  none
23
23
  else
24
- where(id: ids.sample(n))
24
+ where(primary_key => ids.sample(n))
25
25
  end
26
26
  end
27
27
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveSample
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_sample
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - JuanitoFatas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-07 00:00:00.000000000 Z
11
+ date: 2017-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -64,9 +64,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  version: '0'
65
65
  requirements: []
66
66
  rubyforge_project:
67
- rubygems_version: 2.6.2
67
+ rubygems_version: 2.6.12
68
68
  signing_key:
69
69
  specification_version: 4
70
70
  summary: Sample functionality for Active Record.
71
71
  test_files: []
72
- has_rdoc: