positioning 0.4.6 → 0.4.7
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +9 -0
- data/lib/positioning/mechanisms.rb +1 -3
- data/lib/positioning/version.rb +1 -1
- metadata +3 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0484d3a5e2c66cc3a052ddf7b84a77fb976062c1b8e4cff8aabf07606708917f'
|
4
|
+
data.tar.gz: e0c48bf52a2c6172f9aeef7cd65a90d766d648249d2d4c64463cc34541e85e63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37200c924df3d9e7a7ce7ab32aba09f1e3dcda62e505eee98ad0b35239dbe26264b17402612d85ec97169ae4d678e484227812195b5d5db4aa3d96a647ff09bd
|
7
|
+
data.tar.gz: 549596a8a3c6fe27297b746f92a1d2ed787c4d48405a12b9e0d10134ecd38aa8b326cc5d0f9065c1bc117cb416862322d1ce1fbabab700a3856a20943b1f9944
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.4.7] - 2025-08-09
|
4
|
+
|
5
|
+
- Fix `solidify_position` so that it properly raises an error for an invalid string position.
|
6
|
+
|
3
7
|
## [0.4.6] - 2025-05-01
|
4
8
|
|
5
9
|
- Fix healing for positioning with nullable scope (parent in trees, for example). Thanks @pyromaniac!
|
data/README.md
CHANGED
@@ -267,6 +267,15 @@ item.update list: other_list, position: {after: 11}
|
|
267
267
|
|
268
268
|
It's important to note that in the examples above, `other_item` must already belong to the `other_list` scope.
|
269
269
|
|
270
|
+
##### Single Table Inheritance and Abstract Models
|
271
|
+
Positioning requires a concrete table to work with and considers all records within that table as being in some scope. Therefore, it currently isn't possible to use `positioned` on abstract subclasses or when using STI. All calls to `position` must be on the base class.
|
272
|
+
|
273
|
+
If you must position child models separately, scope their position by the `type` column.
|
274
|
+
|
275
|
+
```rb
|
276
|
+
positioned on: [:type]
|
277
|
+
```
|
278
|
+
|
270
279
|
## Concurrency
|
271
280
|
|
272
281
|
The queries that this gem runs (especially those that seek the next position integer available) are vulnerable to race conditions. To this end, we lock the scope records to ensure that our model callbacks that determine and assign positions run sequentially. Previously we used an Advisory Lock for this purpose but this was difficult to test and a bit overkill in most situations. Where a scope doesn't exist, we lock all the records in the table.
|
@@ -162,9 +162,7 @@ module Positioning
|
|
162
162
|
solidified_position -= 1 if in_positioning_scope? && position_was < solidified_position
|
163
163
|
|
164
164
|
self.position = solidified_position
|
165
|
-
|
166
|
-
|
167
|
-
unless position.is_a? Integer
|
165
|
+
else
|
168
166
|
raise Error.new,
|
169
167
|
%(`#{@column}` must be an Integer, :first, :last, ) +
|
170
168
|
%{before: (#{base_class.name}, #{primary_key}, nil, or ""), } +
|
data/lib/positioning/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: positioning
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brendon Muir
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activesupport
|
@@ -38,7 +37,6 @@ dependencies:
|
|
38
37
|
- - ">="
|
39
38
|
- !ruby/object:Gem::Version
|
40
39
|
version: '6.1'
|
41
|
-
description:
|
42
40
|
email:
|
43
41
|
- brendon@spike.net.nz
|
44
42
|
executables: []
|
@@ -65,7 +63,6 @@ metadata:
|
|
65
63
|
source_code_uri: https://github.com/brendon/positioning
|
66
64
|
changelog_uri: https://github.com/brendon/positioning/blob/main/CHANGELOG.md
|
67
65
|
funding_uri: https://github.com/sponsors/brendon
|
68
|
-
post_install_message:
|
69
66
|
rdoc_options: []
|
70
67
|
require_paths:
|
71
68
|
- lib
|
@@ -80,8 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
77
|
- !ruby/object:Gem::Version
|
81
78
|
version: '0'
|
82
79
|
requirements: []
|
83
|
-
rubygems_version: 3.
|
84
|
-
signing_key:
|
80
|
+
rubygems_version: 3.7.1
|
85
81
|
specification_version: 4
|
86
82
|
summary: Simple positioning for Active Record models.
|
87
83
|
test_files: []
|