DmitryTsepelev / store_model

Work with JSON-backed attributes as ActiveRecord-ish models

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion: Add prefix to enum types

acetinick opened this issue · comments

Hi,

Great library, have migrated already out settings stores to this library and works great.

One thing that it would be great is for enum types to support prefix settings.

Currently to avoid conflicts for many enum settings it would be good to have this similar feature from enum rails core

eg.

enum :authentication_method, %i[email phone], default: :email
enum :notification_method, %i[email phone], default: :email

currently we get arround this by doing this,

enum :authentication_method, %i[authentication_method_email authentication_method_phone], default: :authentication_method_email
enum :notification_method, %i[notification_method_email notification_method_phone], default: :notification_method_email

however, would be cleaner to have

enum :authentication_method, %i[email phone], default: :email, _prefix: true
enum :notification_method, %i[email phone], default: :email, _prefix: true

Hi @acetinick, nice to hear that the gem was useful to you 🙂 This feature definitely makes sense, do you want to take a lead on implementing it?

Yep sure, would be something I can help out with over the coming weeks.

Implemented in #102