An example use case would be where for example, you are getting an object through your api from the client. Your client doesn't know about your classes, but sends back the type attribute. Based off that attribute you want to load the right class and then call "create" or "new".
You have validations on a subclass basis, so it is important to load the write subclass so that the business logic runs... On Sunday, July 9, 2017 at 8:26:36 AM UTC-7, Jeremy Evans wrote: > > On Sunday, July 9, 2017 at 3:14:01 AM UTC-7, Aryk Grosz wrote: >> >> Hi Jeremy, >> >> A few times I wanted to reuse logic in the single_table_inheritance >> module like: >> >> # Return an instance of the class specified by sti_key, >> # used by the row_proc. >> def sti_load(r) >> sti_class(sti_model_map[r[sti_key]]).call(r) >> end >> >> >> >> Would you be open to splitting this up: >> >> def sti_class_from_sti_key(key) >> sti_class(sti_model_map[key]) >> end >> >> >> That way someone could call new on that or do other logic. >> > > That sounds fine, but could you give an example use case? > > Thanks, > Jeremy > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
