lexorank 0.1.2 → 0.1.3

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: 016c148a28989a35ab6afd0184625900cbec71dac5dcfa981cac45403c9aa0d5
4
- data.tar.gz: 46cfe89fa41fb20b511235122b8511702ddfba532c1d475d7dfe2cec337a2e7c
3
+ metadata.gz: 4643e7db16d6b8ed5dcb807f80d2350663f168b8b66e0e81791d1c746fd1a17a
4
+ data.tar.gz: 2fdf4f043ef14b8fab235422f409b151fc1117000ea304c2612ccb0e71a079ca
5
5
  SHA512:
6
- metadata.gz: 969a110cb1cc3c60ea599b6b747326a6f86c57de0a261c0f369d0691108c59f757e8d0d12b2d669bc2dbfefe275dd83e1d851f6f6b181ac1dec917388f54458c
7
- data.tar.gz: 249348edc5ffeb92cc42a1d98e585c671560443d53e5a150b64d5674f49ceaf7857e3ca80208a8da0de20ca380aa5598fa5726672842c833294d2710d4a68e4a
6
+ metadata.gz: 27fb2b029e5eab9088a1236b0b0cb18688e0a8efdee64cfedee869dd1b72a7257056757d59989dd6a0ffc8164af77282108258d066fd8462a1dfc0f074128b61
7
+ data.tar.gz: 9dda1742be04a290c3b68defcbb6f88302665ee01ff0f5cbb4086a62a004ee95e7ebe381f1280414dee6d84a8810a177e712ae4f86eee4c8e243a40a5c20d216
@@ -60,10 +60,7 @@ module Lexorank::Rankable
60
60
  if position == 0
61
61
  [nil, collection.first]
62
62
  else
63
- # if item is currently in front of the index we just use position otherwise position - 1
64
- # if the item has no rank we use position - 1
65
- position -= 1 if !self.send(self.class.ranking_column) || collection.map(&:id).index(self.id) > position
66
- collection.offset(position).limit(2)
63
+ collection.where.not(id: self.id).offset(position - 1).limit(2)
67
64
  end
68
65
 
69
66
  rank =
@@ -85,6 +82,9 @@ module Lexorank::Rankable
85
82
  move_to!(0)
86
83
  end
87
84
 
85
+ def no_rank?
86
+ !self.send(self.class.ranking_column)
87
+ end
88
88
  end
89
89
 
90
90
  end
@@ -1,3 +1,3 @@
1
1
  module Lexorank
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lexorank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Böhme
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-08 00:00:00.000000000 Z
11
+ date: 2021-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
168
  requirements: []
169
- rubygems_version: 3.2.3
169
+ rubygems_version: 3.2.15
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: Store order of your models by using lexicographic sorting.