[Catalyst] Creating Good Adaptor or Bridge Models (WAS: Creating a thin Model)

Matt S Trout dbix-class at trout.me.uk
Wed May 23 15:17:39 GMT 2007


On Wed, May 23, 2007 at 11:16:38AM +0000, Zbigniew Lukasiak wrote:
> Some time ago I had this idea that the declarations we put into
> MySite::Model::DBIC are entirely superfluous and that it would be much
> simpler if we just needed to declare in the config file that the model
> uses the MySite::Schema and have it generated automatically.  Matt
> agreed and asked me to write tests for that feature - but I did not
> know what should go into these tests.
> 
> So the idea is to be able to declare in the config file:
> 
> Model::ModelName :
>   instantiate : MySite::Schema
> 
> and then use $c->model(ModelName) without actually creating the
> MySite::Model::ModelName package anywhere.

Maybe something more like

setup_components:
  Model::ModelName:
    class: Catalyst::Model::DBIC::Schema
    instantiate:
      schema_class: My::Schema
      connect_info: ....

?

> So what are the tests that would go here?  I can think only about two:
> 
> - that $c->model(ModelName) is a Catalyst::Model

That shouldn't even be required, an instantiate section in the config could
indicate calling ->COMPONENT if present and ->new if not, and the lack of
one would mean simply adding the class maybe?

> - that the config values are correctly used
> 
> Is there anything more?  This would automate what you put in the
> first, simpler method of model building.

How does the above sound?

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/             http://www.shadowcatsystems.co.uk/ 



More information about the Catalyst mailing list