attr_json
attr_json copied to clipboard
Defining attrs on runtime?
I was thinking - would that be possible to somehow define attr_jsons on record on runtime rather than defining them in advance on model definition?
Something like:
record = MyModel.last
record.define_attr_json :my_string, :string
record.my_string #=> "Hello"
In my current setup, every customer (tenant) of my app can define his own set of custom fields for "Project" model therefore i can't have them defined globally, i have to be able to re-load whatever custom fields tenant has defined on every target record load.
Also, i'm totally okay with some #send(:private_method)
hacking or any sort of hacking to make that work :)