i'm playing around with EIEIO and jeison.el, trying to model a json rest api for an emacs client.
if i define a class, its slots can also specify a :type
, and this can be another class i have created. when i instantiate the object, the slot contains another object, also instantiated, of the second class. which is all well and good.
but sometimes the json api also returns an array of objects, and i was hoping to model that similarly, as a list of objects, that will also instantiate like a standalone object in a slot does.
is this possible with EIEIO? it seems like the :type
keyword can't handle this, and i'm not sure how else to go about it.
i realise i could just have the objects in the slot could just be a list of alists or similar, but i would like to model the api cleanly, and also some of the objects it returns lists of have to be classes anyway, as they are used elsewhere in the api on their own, i.e. not as slots in, or objects of, other objects. so it seems messy to have them be classes/ojects elsewhere, and then only alists when part of another object.
can decoder or translator functions be used somehow? i'm an oop/eieio newbie, hoping to learn more about it by exploring, and i hit this snag early on. i'd be grateful for any pointers on how to go about this, or where to read up further.
EDIT:
i had a try writing a method that would loop over a list of entries in a given slot and return an object for each entry. i added this to the slot under the :writer
keyword, but the EIEIO manual suggests that maybe this isn't implemented:
‘:writer’
Name of a generic function which will write this slot.
This option is in the CLOS spec, but is not fully compliant in
EIEIO.
perhaps what i'm looking to do is simply not possible in EIEIO?