DmitryTsepelev / store_model

Work with JSON-backed attributes as ActiveRecord-ish models

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Aliasing an attribute

ivanyv opened this issue · comments

commented

Is it possible to do something like this?

attribute :settings, Setting.to_type, alias: :user_settings

And then access the original jsonb through settings, but user_settings would return the StoreModel Object.

Simply aliasing the settings method to user_settings does not work.

Hi @ivanyv, I was going to suggest aliasing and surprized that it does not work 🙂We do not patch attribute method yet (cause it comes from Attributes API) but I guess it won't be difficult if we know how to alias under the hood