positioning 0.2.4 → 0.2.5
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/lib/positioning/mechanisms.rb +10 -14
- data/lib/positioning/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '04080c2e27b8d0545c86d69fb4a7794530971ca19c1e9db969181ff01bab2f96'
|
4
|
+
data.tar.gz: 3e81bbd7406e0221378d78e4404629c70eb84d82849d96c6a3506982cbfdf756
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef7cd59860371c435080925d38d994ac8b6a538de4c3a2687f602959792d7d9d1ba91c3df8c91c74ecf284f65ac432d7fc88b2d7ea3710c22c5f27641398f58e
|
7
|
+
data.tar.gz: 108ded7f5f7756f05dbc19b863bc723ed4e32e41737b6eecded5d0a6e0ab8a19e65a05bb330ce3625f5a61736ed0c4f816a3183efde8b7d17d0bcfbd5518ddda
|
data/CHANGELOG.md
CHANGED
@@ -50,12 +50,8 @@ module Positioning
|
|
50
50
|
@positioned.class.base_class
|
51
51
|
end
|
52
52
|
|
53
|
-
def primary_key_column
|
54
|
-
base_class.primary_key
|
55
|
-
end
|
56
|
-
|
57
53
|
def primary_key
|
58
|
-
|
54
|
+
base_class.primary_key
|
59
55
|
end
|
60
56
|
|
61
57
|
def quoted_column
|
@@ -63,7 +59,7 @@ module Positioning
|
|
63
59
|
end
|
64
60
|
|
65
61
|
def record_scope
|
66
|
-
base_class.where(
|
62
|
+
base_class.where(primary_key => [@positioned.id])
|
67
63
|
end
|
68
64
|
|
69
65
|
def position
|
@@ -125,19 +121,19 @@ module Positioning
|
|
125
121
|
when nil, "", :last, {before: nil}, {before: ""}
|
126
122
|
self.position = last_position
|
127
123
|
when Hash
|
128
|
-
relative_position,
|
124
|
+
relative_position, relative_record_or_id = *position_before_type_cast.first
|
129
125
|
|
130
126
|
unless [:before, :after].include? relative_position
|
131
127
|
raise Error.new, "relative `#{@column}` must be either :before, :after"
|
132
128
|
end
|
133
129
|
|
134
|
-
|
135
|
-
|
130
|
+
relative_id = if relative_record_or_id.is_a? base_class
|
131
|
+
relative_record_or_id.id
|
136
132
|
else
|
137
|
-
|
133
|
+
relative_record_or_id
|
138
134
|
end
|
139
135
|
|
140
|
-
relative_record_scope = positioning_scope.where(
|
136
|
+
relative_record_scope = positioning_scope.where(primary_key => [relative_id])
|
141
137
|
|
142
138
|
unless relative_record_scope.exists?
|
143
139
|
raise Error.new, "relative `#{@column}` record must be in the same scope"
|
@@ -153,8 +149,8 @@ module Positioning
|
|
153
149
|
unless position.is_a? Integer
|
154
150
|
raise Error.new,
|
155
151
|
%(`#{@column}` must be an Integer, :first, :last, ) +
|
156
|
-
%{before: (#{base_class.name}, #{
|
157
|
-
%{after: (#{base_class.name}, #{
|
152
|
+
%{before: (#{base_class.name}, #{primary_key}, nil, or ""), } +
|
153
|
+
%{after: (#{base_class.name}, #{primary_key}, nil or ""), nil or ""}
|
158
154
|
end
|
159
155
|
end
|
160
156
|
|
@@ -175,7 +171,7 @@ module Positioning
|
|
175
171
|
end
|
176
172
|
|
177
173
|
def in_positioning_scope?
|
178
|
-
@positioned.persisted? && positioning_scope.where(
|
174
|
+
@positioned.persisted? && positioning_scope.where(primary_key => [@positioned.id]).exists?
|
179
175
|
end
|
180
176
|
|
181
177
|
def positioning_scope_changed?
|
data/lib/positioning/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: positioning
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brendon Muir
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|