rsb-settings 0.9.1 → 0.9.3
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/lib/rsb/settings/locked_setting_error.rb +10 -0
- data/lib/rsb/settings/resolver.rb +9 -0
- data/lib/rsb/settings/test_helper.rb +5 -0
- data/lib/rsb/settings.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 60e1969f05f8172c516648d34871ebf460f7e3ec84f6b754c406e76e9c8a2949
|
|
4
|
+
data.tar.gz: bfbe6b45703c6d6a6ac4e63da8915399174c89ded5b576756e4d827485aec71c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 90b8ff559f75ca6be8c5469be6837e930d1a8f4d81e3bf05dcd9f1fb14c81b594626587f1082109070c275d3a23d59778b14085ac240be1b38cbb6982cc0163e
|
|
7
|
+
data.tar.gz: ba0c46a3229e0083553b064109d71567a0b6e3768af457e5be6a5bf8f94ad5495ce00b29e6d0f787a740907cccc205b426245ee81924d799a450bb1c9a75b49e
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RSB
|
|
4
|
+
module Settings
|
|
5
|
+
# Raised when attempting to set a value for a locked setting key.
|
|
6
|
+
# Locked keys are configured via RSB::Settings.configure { |c| c.lock("category.key") }
|
|
7
|
+
# and cannot be modified programmatically or via the admin UI.
|
|
8
|
+
class LockedSettingError < StandardError; end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -18,8 +18,17 @@ module RSB
|
|
|
18
18
|
value
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
# Persists a setting value to the database.
|
|
22
|
+
#
|
|
23
|
+
# @param category [String] the setting category
|
|
24
|
+
# @param key [String] the setting key within the category
|
|
25
|
+
# @param value [Object] the value to persist
|
|
26
|
+
# @raise [RSB::Settings::LockedSettingError] if the key is locked via configuration
|
|
27
|
+
# @return [void]
|
|
21
28
|
def set(category, key, value)
|
|
22
29
|
full_key = "#{category}.#{key}"
|
|
30
|
+
raise RSB::Settings::LockedSettingError, "Setting '#{full_key}' is locked" if @configuration.locked?(full_key)
|
|
31
|
+
|
|
23
32
|
old_value = get(category, key)
|
|
24
33
|
new_value = value
|
|
25
34
|
|
|
@@ -6,6 +6,11 @@ module RSB
|
|
|
6
6
|
extend ActiveSupport::Concern
|
|
7
7
|
|
|
8
8
|
included do
|
|
9
|
+
setup do
|
|
10
|
+
RSB::Settings.reset!
|
|
11
|
+
RSB::Settings::Setting.delete_all if RSB::Settings::Setting.table_exists?
|
|
12
|
+
end
|
|
13
|
+
|
|
9
14
|
teardown do
|
|
10
15
|
RSB::Settings.reset!
|
|
11
16
|
RSB::Settings::Setting.delete_all if RSB::Settings::Setting.table_exists?
|
data/lib/rsb/settings.rb
CHANGED
|
@@ -10,6 +10,7 @@ require 'rsb/settings/registry'
|
|
|
10
10
|
require 'rsb/settings/resolver'
|
|
11
11
|
require 'rsb/settings/configuration'
|
|
12
12
|
require 'rsb/settings/validation_error'
|
|
13
|
+
require 'rsb/settings/locked_setting_error'
|
|
13
14
|
require 'rsb/settings/locale_helper'
|
|
14
15
|
require 'rsb/settings/locale_middleware'
|
|
15
16
|
require 'rsb/settings/seo_settings_schema'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rsb-settings
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aleksandr Marchenko
|
|
@@ -44,6 +44,7 @@ files:
|
|
|
44
44
|
- lib/rsb/settings/engine.rb
|
|
45
45
|
- lib/rsb/settings/locale_helper.rb
|
|
46
46
|
- lib/rsb/settings/locale_middleware.rb
|
|
47
|
+
- lib/rsb/settings/locked_setting_error.rb
|
|
47
48
|
- lib/rsb/settings/registry.rb
|
|
48
49
|
- lib/rsb/settings/resolver.rb
|
|
49
50
|
- lib/rsb/settings/schema.rb
|