Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You're trying to create a Moose class and it's not compatible with the regular <a href="http://metacpan.org/module/Catalyst%3a%3aModel%3a%3aAdaptor" rel="nofollow">Catalyst::Model::Adaptor</a> usage; and you are not, in your example, using any Moose functionality anyway. This is probably, lightly tested, what you really want.</p> <pre><code>package MyApp::Model::TheSchwartz; use parent "Catalyst::Model::Adaptor"; __PACKAGE__-&gt;config( class =&gt; "TheSchwartz" ); sub mangle_arguments { my ($self, $args) = @_; if ( $args-&gt;{databases} ) { if (ref ( $args-&gt;{databases} ) eq "HASH" ) { my %db = %{ $args-&gt;{databases} }; $args-&gt;{databases} = [ \%db ]; } } return %{ $args } } 1; </code></pre> <p><a href="http://metacpan.org/module/parent" rel="nofollow">parent</a> is sometimes considered preferable to <a href="http://metacpan.org/module/base" rel="nofollow">base</a> but they are almost interchangeable.</p> <h3>Update, 26 July 2012</h3> <p>FWIW, this is a working version of TheSchwartz being used as a model in one of my apps; it's been in production for... 2 years I think. The Cat version is a few back but not 2 years old. I'm sorry I didn't dig it up before&ndash;</p> <pre><code>package MyApp::Model::TheSchwartz; use parent "Catalyst::Model::Adaptor"; __PACKAGE__-&gt;config( class =&gt; "TheSchwartz" ); sub mangle_arguments { %{$_[1]} } 1; __END__ # In MyApp.pm "Model::TheSchwartz" =&gt; { args =&gt; { verbose =&gt; 1, databases =&gt; [{ dsn =&gt; "dbi:mysql:MyAppDB;host=my_host", user =&gt; "something", pass =&gt; "somethingsecret", }], } }, </code></pre> <p>The <a href="http://metacpan.org/module/Config%3a%3aGeneral" rel="nofollow">Config::General</a> format you're using is probably to blame your ref/HASH handling. You can see from my <code>mangle_arguments</code> that if the args are properly formed, there is no need to do anything with them at all but flatten them to the list TheSchwartz expects.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload