positioning 0.1.3 → 0.1.5

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: 20e2658aa131e9c641fc3b5bdd2f685d64af56d56a53abb0eef4a25f12b4f293
4
- data.tar.gz: 61d5b5e9afb5ad0d037ccb2a14185dfe0fca705cb0850f89e436d1e371608d9f
3
+ metadata.gz: 1a18c3175781c6d4509ea42db1583e68bb2e7258e9c0b99201b1b551fc50ccd7
4
+ data.tar.gz: 8ceb46c8c93882d2e82e88f4d9c5bcafb3371830dd6d5169cf23dd76d8ba6cd0
5
5
  SHA512:
6
- metadata.gz: 51c9fa527fea19618a9b5362cc81cce367dfa15039328a3085598fd1c5ea8e2f6b8bcf92b650c82d83fb0e221ef307b893580a4172fb0f3c94200a8cdb1579c4
7
- data.tar.gz: 8ca5d909229d1c2d8f1712c5ca21275ac75f733de7bf799c7c3d8777f609116efa6127b7a657d09e6a5396769c5451a8a44218941e15d836abaa3b99e954bef3
6
+ metadata.gz: 19ced8dddfaefd60c644f19ac576513185e5f3dfa52e8aaabab59f390042f1937bfd3f24874bd228012b337f9f843963b6261b25133d5d1d54f2d606d5c08b7a
7
+ data.tar.gz: ac66e6a3eeb7ab20d54511640c9c1e1e20090b9cd0d01cf583031944d42e7f517dc603afc9b59b49c35617a437f5ebbdbf406e0b1cc71beff3413fd8cf73d76b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.5] - 2024-03-04
4
+
5
+ - Allow empty strings to represent nil for the purposes of solidifying a position
6
+
7
+ ## [0.1.4] - 2024-03-04
8
+
9
+ - Fix bug relating to relative position hash coming from Rails being a Hash With Indifferent Access
10
+
3
11
  ## [0.1.3] - 2024-03-04
4
12
 
5
13
  - Internal refactoring of Mechanisms for clarity
@@ -98,14 +98,14 @@ module Positioning
98
98
  def solidify_position
99
99
  position_before_type_cast = @positioned.read_attribute_before_type_cast @column
100
100
  position_before_type_cast.to_sym if position_before_type_cast.is_a? String
101
- position_before_type_cast.symbolize_keys! if position_before_type_cast.is_a? Hash
101
+ position_before_type_cast = position_before_type_cast.symbolize_keys if position_before_type_cast.is_a? Hash
102
102
 
103
103
  case position_before_type_cast
104
104
  when Integer
105
105
  self.position = position_before_type_cast.clamp(1..last_position)
106
- when :first, {after: nil}
106
+ when :first, {after: nil}, {after: ""}
107
107
  self.position = 1
108
- when nil, :last, {before: nil}
108
+ when nil, "", :last, {before: nil}, {before: ""}
109
109
  self.position = last_position
110
110
  when Hash
111
111
  relative_position, relative_record_or_primary_key = *position_before_type_cast.first
@@ -135,8 +135,9 @@ module Positioning
135
135
 
136
136
  unless position.is_a? Integer
137
137
  raise Error.new,
138
- "`#{@column}` must be an Integer, :first, :last, before: #{base_class.name}, " \
139
- "after: #{base_class.name}, or nil"
138
+ %(`#{@column}` must be an Integer, :first, :last, ) +
139
+ %{before: (#{base_class.name}, #{primary_key_column}, nil, or ""), } +
140
+ %{after: (#{base_class.name}, #{primary_key_column}, nil or ""), nil or ""}
140
141
  end
141
142
  end
142
143
 
@@ -1,3 +1,3 @@
1
1
  module Positioning
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: positioning
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brendon Muir