super_settings 2.0.1 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/VERSION +1 -1
- data/lib/super_settings/coerce.rb +2 -6
- data/lib/super_settings/storage/active_record_storage.rb +7 -7
- 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: deffd163ccbba074051f5e7df4138216f24da7c8fa068c5a25fdaa7c83326799
|
4
|
+
data.tar.gz: af00d68c45251327f0e73867c16bdb4171110929f02290db374178c88718f0ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d496dfbfeaba9952c624f15680323d83fe055a03f48f17c660a5dee8e3512a4692bbe249212bfdf1830026ec0e726cb312acc0134a8c8260e95433b6c325abc8
|
7
|
+
data.tar.gz: de6887cbbe6ec06ba1cb20e75769377008a5d7fa4eb1a55bcbb6be87e3cdff508890209a0984dc3cdf4ae293d895ce946eb807582097c65e052a9f0b0fcef081
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## 2.0.3
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
|
11
|
+
- Fixed ActiveRecord code handling changing a setting key to one that had previously been used. The previous code relied on a unique key constraint error to detect this condition, but Postgres does not handle this well since it invalidates the entire transaction. Now the code checks for the uniqueness of the key before attempting to save the setting.
|
12
|
+
|
13
|
+
## 2.0.2
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
|
17
|
+
- Coercing a string to a boolean is now case insensitive (i.e. "True" is interpreted as `true` and "False" is interpreted as `false`).
|
18
|
+
|
7
19
|
## 2.0.1
|
8
20
|
|
9
21
|
### Added
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.3
|
@@ -7,14 +7,10 @@ module SuperSettings
|
|
7
7
|
class Coerce
|
8
8
|
# rubocop:disable Lint/BooleanSymbol
|
9
9
|
FALSE_VALUES = Set.new([
|
10
|
-
false, 0,
|
11
10
|
"0", :"0",
|
12
11
|
"f", :f,
|
13
|
-
"F", :F,
|
14
12
|
"false", :false,
|
15
|
-
"
|
16
|
-
"off", :off,
|
17
|
-
"OFF", :OFF
|
13
|
+
"off", :off
|
18
14
|
]).freeze
|
19
15
|
# rubocop:enable Lint/BooleanSymbol
|
20
16
|
|
@@ -29,7 +25,7 @@ module SuperSettings
|
|
29
25
|
elsif blank?(value)
|
30
26
|
nil
|
31
27
|
else
|
32
|
-
!FALSE_VALUES.include?(value)
|
28
|
+
!FALSE_VALUES.include?(value.to_s.downcase)
|
33
29
|
end
|
34
30
|
end
|
35
31
|
|
@@ -89,17 +89,17 @@ module SuperSettings
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def save!
|
92
|
-
|
92
|
+
# Check if another record with the same key exists. If it does, then we need to update
|
93
|
+
# that record instead and delete the current one.
|
94
|
+
duplicate = @model.class.find_by(key: @model.key)
|
95
|
+
if duplicate.nil? || duplicate == @model
|
93
96
|
@model.save!
|
94
|
-
|
95
|
-
# Gracefully handle duplicate key constraint on the database; in this case the existing
|
96
|
-
# record should be updated.
|
97
|
-
duplicate = @model.class.find_by(key: @model.key)
|
98
|
-
raise e if duplicate == @model
|
97
|
+
else
|
99
98
|
duplicate.raw_value = @model.raw_value
|
100
99
|
duplicate.value_type = @model.value_type
|
101
100
|
duplicate.description = @model.description
|
102
|
-
duplicate.deleted =
|
101
|
+
duplicate.deleted = @model.deleted
|
102
|
+
|
103
103
|
@model.transaction do
|
104
104
|
if @model.persisted?
|
105
105
|
@model.reload.update!(deleted: true)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: super_settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Durand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|