Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
faster proxy objects
  • Loading branch information
kraih committed Aug 10, 2014
1 parent 5cddf07 commit e690351
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Mojolicious/Renderer.pm
Expand Up @@ -73,7 +73,7 @@ sub get_helper {
if (my $h = $self->helpers->{$name} || $self->{proxy}{$name}) { return $h }
return undef unless grep {/^\Q$name\E\./} keys %{$self->helpers};
return $self->{proxy}{$name}
= sub { Mojolicious::Renderer::_Proxy->new(c => shift, p => $name) };
= sub { bless [shift, $name], 'Mojolicious::Renderer::_Proxy' };
}

sub render {
Expand Down Expand Up @@ -249,15 +249,15 @@ sub _render_template {
}

package Mojolicious::Renderer::_Proxy;
use Mojo::Base -base;
use Mojo::Base -strict;

sub AUTOLOAD {
my $self = shift;

my ($package, $method) = split /::(\w+)$/, our $AUTOLOAD;
my $c = $self->{c};
my $c = $self->[0];
Carp::croak qq{Can't locate object method "$method" via package "$package"}
unless my $helper = $c->app->renderer->get_helper("$self->{p}.$method");
unless my $helper = $c->app->renderer->get_helper("$self->[1].$method");
return $c->$helper(@_);
}

Expand Down

0 comments on commit e690351

Please sign in to comment.