Skip to content

Instantly share code, notes, and snippets.

@backroot
Last active March 20, 2016 14:31
Show Gist options
  • Save backroot/62f010c884314638da22 to your computer and use it in GitHub Desktop.
Save backroot/62f010c884314638da22 to your computer and use it in GitHub Desktop.
# MyApp.pm
package MyApp;
use Mojo::Base 'Mojolicious';
use MyApp::Model;
has 'model' => sub {MyApp::Model->new};
# MyModel
package MyApp::MyModel;
use Mojo::Base 'Mojolicious';
sub hello {
  my $self = shift;
  print('Hello');
}
1;
# Model
package MyApp::Model;
use Mojo::Base 'Mojolicious';
use MyApp::Model::MyModel;
has 'my_model' => sub { MyApp::Model::MyModel->new };
1;
# Using Model
$self->app->model->my_model->hello;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment