brainspec / enumerize

Enumerated attributes with I18n and ActiveRecord/Mongoid support
MIT License
1.72k stars 190 forks source link

fix: enumerize with string store accessor keys #441

Closed 4ndypanda closed 1 month ago

4ndypanda commented 6 months ago

Ensures Enumerize is agnostic to whether the key to a store accessor is a string or symbol.

Re-opening https://github.com/brainspec/enumerize/pull/405 but with fix to not generate string objects with #to_s from original PR. Because ActiveRecord::Store's .store and .store_accessor methods allow string names for attribute names, we should be able to handle them. This has come up for me when dealing with meta-programming where one dynamically defines store attributes.

SalvatoreT commented 1 month ago

Hey @nashby, when you get a chance, can you please take a look at this bug fix as well? I think @4ndypanda might need to resolve a conflict, but it looks otherwise good to go!

4ndypanda commented 1 month ago

Note to self, rebase after merging https://github.com/brainspec/enumerize/pull/450.

nashby commented 1 month ago

@4ndypanda thanks! I pushed a small change https://github.com/brainspec/enumerize/commit/c77d0e3af8069f6d259f362ad779680baa09aa01 since Attribute#name is always a symbol.