Looking for a bit of guidance on design.

I have a growing number of classes that require a DBIx::Class "schema"
attribute.  These classe are used as Models in Catalyst (where they get the
Catalyst app's schema passed in to the constructor), but they are also used
in command line tools and cron jobs.

It makes sense to coerce a URI object from a string, and even a DateTime
from an integer or a string -- and MooseX::Types::DateTime and
MooseX::Types::URI do that. But MooseX::Types::DBIx::Class does not coerce
a schema object.

Is there any reason I would not want to coerce a schema from a hashref?

I guess another option would be a role that includes individual attributes
for schema class, dsn, user, passwords, and \%options and use a
_build_schema method.   This is an approach I've used in the past.

BTW, I used DBIC as a familiar example, but many of my classes need more
than just a DBIC schema -- they often need a logger, and a few other
classes so this question isn't limited to building a schema object.

-- 
Bill Moseley
mose...@hank.org

Reply via email to