tunable 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 844872db005ce594870ba86746820e4299bcecbecaba9606a6e4e7cc2a39177b
4
- data.tar.gz: 5187361fbcfd3af0a04f5d02ed03e62b3496edd5f962e9d57a7579af4f914529
3
+ metadata.gz: 0ee1f672f4e874012a7dec7f37aab3ff0ceffbea47ad1c3943a7711209446f5e
4
+ data.tar.gz: 7854d4f7f8871492b60dabe7589a9b6158ca079a3b6cfb102ca0dad94bc17c69
5
5
  SHA512:
6
- metadata.gz: 615660905363b14900b5d0773f5a90e836fbd3d5a83888dd52359515563d2715c41e74e8db749c6dc9af7acada93de6df0da4345d868c86df9e580a554994574
7
- data.tar.gz: dcc95b1b796ef5c1ab334c1c3be6e02cddfd90266a61e508d970b73322bca2db0d529ea087fede88602d87d3cd48e64fd595ac4b8d3e3d2dc94af8d5e1d2b645
6
+ metadata.gz: 20dcacdea0c8ddf6375d6c4301e325e50da5d7179f13808c779f10c1449baa8f1ab4ae7a98adf06f478359b13640721b725142c5943e655ec529ca21f8f9e61d
7
+ data.tar.gz: 35780c6cb907862d323ab12bd57b3b0f9d3288008d34a3d7026e60bf7e49840e01a31111330314eaea06e13a0fa4c5d7d7fcd4bc435f010dbe08e6a174ba8687
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # specified in gemspec
4
4
  gemspec
data/lib/tunable/model.rb CHANGED
@@ -264,9 +264,11 @@ module Tunable
264
264
 
265
265
  modified_settings.each do |context, fields|
266
266
  fields.each do |key, value|
267
+
267
268
  # even though we do normalize on the setters, not all settings are
268
269
  # main settings, so we need to make sure we normalize here again
269
- normalized_value = Tunable.normalize_value(value)
270
+ default = self.class.default_settings(context)[key.to_sym]
271
+ normalized_value = Tunable.normalize_value(value, default.nil? ? nil : default.class)
270
272
 
271
273
  # class.base_class returns name of parent class for STI models
272
274
  new_settings << [context.to_s, key.to_s, normalized_value, self.id, self.class.base_class.name]
@@ -6,10 +6,10 @@ module Tunable
6
6
  FALSIES = ['false', 'f', 'off', 'no', 'n'].freeze
7
7
 
8
8
  def normalize_value(val, type = nil)
9
- # if [TrueClass, FalseClass].include?(type)
10
- # return false if val.to_s == '0'
11
- # return true if val.to_s == '1'
12
- # end
9
+ if type && [TrueClass, FalseClass].include?(type)
10
+ return false if val.to_s == '0'
11
+ return true if val.to_s == '1'
12
+ end
13
13
 
14
14
  return true if TRUTHIES.include?(val.to_s)
15
15
  return false if FALSIES.include?(val.to_s)
@@ -26,7 +26,7 @@ module Tunable
26
26
 
27
27
  hash.each do |context, fields|
28
28
  fields.each do |key, val|
29
- if val.blank? && !object.settings_context(context.to_sym)[key.to_sym].nil?
29
+ if (val.nil? || val == '') && !object.settings_context(context.to_sym)[key.to_sym].nil?
30
30
 
31
31
  # setting was present and now deleted
32
32
  object.queue_setting_for_deletion(context, key)
@@ -1,3 +1,3 @@
1
1
  module Tunable
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tunable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomás Pollak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-31 00:00:00.000000000 Z
11
+ date: 2025-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord