Skip to content

Commit

Permalink
better Mojo::Base example
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 6, 2012
1 parent 4273e42 commit f968b5b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/Base.pm
Expand Up @@ -131,7 +131,7 @@ Mojo::Base - Minimal base class for Mojo projects
say $mew->mice;
say $mew->mice(3)->birds(4)->mice;
my $rawr = Tiger->new(stripes => 23);
my $rawr = Tiger->new(stripes => 23, mice => 0);
say $rawr->tap(sub { $_->friend->name('Tacgnol') })->mice;
=head1 DESCRIPTION
Expand Down
12 changes: 6 additions & 6 deletions lib/Mojo/Server.pm
Expand Up @@ -25,21 +25,21 @@ sub build_app {
sub build_tx { shift->app->build_tx }

sub load_app {
my ($self, $file) = @_;
my ($self, $path) = @_;

# Clean up environment
local $ENV{MOJO_APP_LOADER} = 1;
local $ENV{MOJO_EXE};

# Try to load application from script into sandbox
my $app = eval <<EOF;
package Mojo::Server::SandBox::@{[md5_sum($file . $$)]};
my \$app = do \$file;
package Mojo::Server::SandBox::@{[md5_sum($path . $$)]};
my \$app = do \$path;
if (!\$app && (my \$e = \$@ || \$!)) { die \$e }
\$app;
EOF
die qq{Couldn't load application from file "$file": $@} if !$app && $@;
die qq{File "$file" did not return an application object.\n}
die qq{Couldn't load application from file "$path": $@} if !$app && $@;
die qq{File "$path" did not return an application object.\n}
unless blessed $app && $app->isa('Mojo');
return $self->app($app)->app;
}
Expand Down Expand Up @@ -120,7 +120,7 @@ default request handling.
my $app = $server->build_app('Mojo::HelloWorld');
Build application.
Build application from class.
=head2 C<build_tx>
Expand Down

0 comments on commit f968b5b

Please sign in to comment.