[Dbix-class] object as a value of result_class (resultset_class)

Roman Daniel roman.daniel at davosro.cz
Tue Sep 20 09:59:18 GMT 2011


In my app I store instances of several classes (subclasses) in one table.
I try to implement a dispatcher which decides what class to inflate to
according to row data loaded from db.

It seems handy for this dispatcher to be an object instead of class.
In DBIC the setter for result_class is implemented via set_component_class,
which expects its argument to be a class - Class::Inspector->loaded is
called on it.

I can overwrite set_component_class to fallback to set_inherited when
its argument  is a blessed object, but I am not sure whether the whole
idea is not weird. If not do you plan to allow result_class to be an
object? (it can be set to object even now but a warning is issued by
Class::Inspector)

I appreciate any comment

Roman Daniel

After I sent the message I noticed that result_class being a class is
also expected in compose_namespace (used in
Catalyst::Model::DBIC::Schema), where subclasses of result_classes
are created.



More information about the DBIx-Class mailing list