Last active
March 20, 2016 14:31
-
-
Save backroot/62f010c884314638da22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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