<div>I will have a number of modules that define a single record and functions for using that record as a model stored in a database for a webapp.</div><div><br></div><div>There are these nice macros for converting a record to json and json to a record that will basically always look like:</div>
<div><br></div><div>to_json(Record) -></div><div> ?record_to_json(?MODULE, Record).</div><div><br></div><div>to_record(JSON) -></div><div> ?json_to_record(?MODULE, JSON).</div><div><br></div><div>But at times they'll need to be overridden for a specific module/record.</div>
<div><br></div><div>My problem is I'd like to not have to copy/paste these into every module (and they'll be more base functions like these) that is a model. extends would be best since that allows overriding but from the base module I can't reference the module that is inheriting the base module as a macro, so I can't use the json_to_record macro since I can't pass in a macro of the record atom name.</div>
<div><br></div><div>A parse transform won't work either since I don't think I can add a call to a macro like I need.</div><div><br></div><div>Does anyone have any suggestions? Or should I just not use records for this? Records are nice since I'm using mnesia and found those record_to json_to macros!</div>
<div><br></div><div>Thanks,</div><div>Tristan</div>