acts_as_positioned 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +1 -1
- data/lib/acts_as_positioned.rb +5 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 799eb208f9f60590a35f0ee65026162868b8cbebcf99398dff5e544479370852
|
4
|
+
data.tar.gz: 63f0524ba9f67c36e8b6001ad7e4eb25426b92258af63275d037ccd1a15d8e04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 536d83b9bb8e85d5ddb6d5cba419da7480312ed9be8283696c4acce1784db688d9ede39a63a886526a87086ee4bb2a5b52891d0daa77a71b031f978baa3231c4
|
7
|
+
data.tar.gz: d962243e15580e651fc6024c3c55f517c1ffb8f9e0711202bd9cb628c62ad75c6b5786d8e9f56870e26f3cf80ed2f4000e3628742265028177f50b74ba897b6e
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ Suppose you have these records (for all examples this is the starting point):
|
|
52
52
|
The existing records with position greater than or equal to 1 will have their
|
53
53
|
position increased by 1 and the new record (with id 4) is inserted:
|
54
54
|
|
55
|
-
Post.create(position:
|
55
|
+
Post.create(position: 1)
|
56
56
|
|
57
57
|
id | position
|
58
58
|
---+---------
|
data/lib/acts_as_positioned.rb
CHANGED
@@ -36,11 +36,15 @@ module ActsAsPositioned
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def aap_insert_position(column, scope_columns)
|
39
|
+
return if send(column).nil?
|
40
|
+
|
39
41
|
scope = aap_scope(column, scope_columns, false)
|
40
42
|
aap_execute_query(column, scope.where(scope.arel_table[column].gteq(send(column))), true)
|
41
43
|
end
|
42
44
|
|
43
45
|
def aap_remove_position(column, scope_columns)
|
46
|
+
return if send("#{column}_was").nil?
|
47
|
+
|
44
48
|
scope = aap_scope(column, scope_columns, true)
|
45
49
|
aap_execute_query(column, scope.where(scope.arel_table[column].gt(send("#{column}_was"))), false)
|
46
50
|
end
|
@@ -81,7 +85,7 @@ module ActsAsPositioned
|
|
81
85
|
end
|
82
86
|
|
83
87
|
def aap_validate_position(column, scope_columns)
|
84
|
-
return if errors[column].present? || (changes.keys & ([column] + scope_columns)).empty?
|
88
|
+
return if send(column).nil? || errors[column].present? || (changes.keys & ([column] + scope_columns)).empty?
|
85
89
|
|
86
90
|
scope = aap_scope(column, scope_columns, false)
|
87
91
|
options = { attributes: column, allow_nil: true, greater_than_or_equal_to: 0, only_integer: true,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_positioned
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Walter Horstman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.
|
115
|
+
rubygems_version: 2.7.6
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Lightweight ordering of models in ActiveRecord 3 or higher
|