Skip to content

Releases: palkan/store_attribute

2.0.0

13 Dec 04:51
663dea2
Compare
Choose a tag to compare

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

08 Mar 17:01
Compare
Choose a tag to compare

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

17 Mar 15:38
Compare
Choose a tag to compare

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.