Releases: palkan/store_attribute
Releases · palkan/store_attribute
2.0.0
Changes
-
Ruby 3.0+ is required.
-
Default values are now set if the store key is missing by default (i.e., the
store_attribute_unset_values_fallback_to_default
option is now true by default).For v1.x behavior, set the option to
false
globally as follows:StoreAttribute.store_attribute_unset_values_fallback_to_default = false
1.1.0
Features
- Added configuration option to return default values when attribute key is not present in the serialized value.
class ApplicationRecord < ActiveRecord::Base
self.store_attribute_unset_values_fallback_to_default = true
store_attribute :extra, :color, :string, default: "grey"
end
user = User.create!(extra: {})
# without the fallback
user.color #=> nil
# with fallback
user.color #=> "grey"
1.0.0
This release bring major improvements to the way we interact with ActiveRecord:
- Use existing Attributes API and Store API instead of duplicating and monkey-patching
- Dirty-tracking, accessors and prefixes/suffixes are now handled by Rails—we're no longer trying to re-implement this.
Thus, we only provide type coercions for stores. That's it.
P.S. The only internal patch that's left is the MutationTracker patch which allows you to have granular #changes
for stores.