Releases: huacnlee/rails-settings-cached
Releases · huacnlee/rails-settings-cached
v2.9.6
What's Changed
- Fix cache read twice for a single value by @qichunren in #257
Full Changelog: v2.9.5...v2.9.6
v2.9.5
What's Changed
- Update and test for Rails 7.2 by @huacnlee in #247
- Add test for Rails 8.0 by @huacnlee in #249
- Delay loading of Active Record by @casperisfine in #244
New Contributors
- @casperisfine made their first contribution in #244
Full Changelog: v2.9.4...v2.9.5
v2.9.4
What's Changed
- Implement configurable storage backend by @viralpraxis in #242
New Contributors
- @viralpraxis made their first contribution in #242
Full Changelog: v2.9.3...v2.9.4
v2.9.3
v2.9.2
v2.9.1
v2.9.0
What's Changed
- Adds Ruby 3.2 support by @berkos in #232
- Add ability to define custom data types by @MrKirat in #235
Custom type for setting
You can write your custom field type by under RailsSettings::Fields
module.
For example
module RailsSettings
module Fields
class YesNo < ::RailsSettings::Fields::Base
def serialize(value)
case value
when true then "YES"
when false then "NO"
else raise StandardError, 'invalid value'
end
end
def deserialize(value)
case value
when "YES" then true
when "NO" then false
else nil
end
end
end
end
end
Now you can use yes_no
type in you setting:
class Setting
field :custom_item, type: :yes_no, default: 'YES'
end
irb> Setting.custom_item = 'YES'
irb> Setting.custom_item
true
irb> Setting.custom_item = 'NO'
irb> Setting.custom_item
false
New Contributors
Full Changelog: v2.8.3...v2.9.0