Last active
August 29, 2015 14:18
-
-
Save Logioniz/ce2b53c9647cf0204e81 to your computer and use it in GitHub Desktop.
Model class with weaken App.
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
#!/usr/bin/perl | |
# Run with command perl 1.pl get / | |
package AAA; | |
use Scalar::Util 'weaken'; | |
sub new { | |
my ($class, $app) = @_; | |
my $hash = {app => $app}; | |
weaken $hash->{app}; | |
return bless $hash, $class; | |
} | |
sub run_asd { shift->{app}->asd } | |
package main; | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
use Mojolicious::Lite; | |
use Scalar::Util 'weaken'; | |
helper asd => sub { return "\n\nzxc\n\n" }; | |
get '/' => sub { | |
my $c = shift; | |
my $a = AAA->new($c->app); | |
$c->render(text => $a->run_asd); | |
}; | |
app->start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment