activerecord-typedstore
activerecord-typedstore copied to clipboard
Namespaces for accessors
I'm looking to use multiple jsonb columns on the same model. However, it is possible some of those columns will share the same keys, which can lead to problems when using accessors.
Is it currently possible to create namespaces for accessors? For example, something like:
class NotificationSettings < ApplicationRecord
typed_store :email do |s|
namespace :email
s.boolean :enabled, default: false, null: false
....
end
typed_store :push do |s|
namespace :push
s.boolean :enabled, default: false, null: false
....
end
typed_store :sms do |s|
namespace :sms
s.boolean :enabled, default: false, null: false
....
end
end
So that I could access each enabled
setting with an accessor? Like NoficiationSettings.email.enabled?
.
@davidmccoy Ever find a solution for this?
@antarr Not with this gem, I just went with straight jsonb.