ActiveRecord extension which adds typecasting to store accessors
MIT License
Bot releases are visible (Hide)
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"
Published by palkan over 2 years ago
This release bring major improvements to the way we interact with ActiveRecord:
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.