On Tue, Mar 28, 2017 at 2:42 PM, james foss <[email protected]> wrote:

> Is this documented anywhere, just so I can get my head around it?


I doubt that it is because App::Model::Name has nothing to do with
Mojolicious (necessarily).  So with App::Model::Name being completely
independent of your Mojolicious app, you have to pass whatever objects your
Mojo app has to your model.  It's not recommended to pass the entire Mojo
app object (app) to a model because of the whole MVC idea of keeping things
separate, but I think it's appropriate to pass your database object.

Here's information about the model layer in Mojolicious
<http://mojolicious.org/perldoc/Mojolicious/Guides/Growing#Model>.  But it
doesn't talk about passing an object in, in order to "make the separation
of concerns more visible".

You could think about it this way...

If your model needs access to the database, let the model establish the
connection to the database itself instead of the Mojolicious app, and
therefore no need to pass in a db object.  Then when your app needs access
to database level stuff, it asks the model to retrieve and return that data.

I'd be thrilled to see more discussion on this.  This is just my outsider's
understanding of this.

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" 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/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to